CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
3 |9 ^ j( z; ~7 W 以下各特效用的HTML代码相同:
( b1 z5 J- l; I; p* P- O, |0 j7 p<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div> 4 E5 _; X* d9 `6 G6 M
1. CSS动画边框: R# }) P) L0 q( [) U
CSS代码:8 a: v$ |+ f+ _& j# }
@keyframes animated-border {
0% {
box-shadow: 0000rgba(255,255,255,0.4);
}
100% {
box-shadow: 00020pxrgba(255,255,255,0);
}
}
#box {
animation: animated-border 1.5s infinite;
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
border: 2px solid;
border-radius: 10px;
padding: 15px;
} 效果如下:) F+ A m! N( g H( y7 l
1 c- E* n3 m, s. @5 H' ?
( \# R& {( ]2 Z: s5 A
2. CSS图像边框
9 B0 ?3 O9 i6 b# Q) [ ~CSS代码:
@. j( Y/ E' p7 L, R2 \#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
border: 40px solid transparent;
border-image: url(https://image.flaticon.com/icons/svg/648/648787.svg);
border-image-slice: 100%;
border-image-width: 60px;
padding: 15px;
} 效果如下:
1 h: O) v( o5 m0 M& N
4 d2 l6 a0 c1 N/ X, y: ~9 ^8 G" f* K1 }, N# N& [) Q+ D7 d
3.CSS蛇式边框
" X `. b7 B; z! DCSS代码:! z1 c# `# j+ m7 ?
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 15px;
border: 10px dashed #FF5722;
background:
linear-gradient(to top, green, 10px, transparent 10px),
linear-gradient(to right, green, 10px, transparent 10px),
linear-gradient(to bottom, green, 10px, transparent 10px),
linear-gradient(to left, green, 10px, transparent 10px);
background-origin: border-box;
} 效果如下:% n- V O* e$ ?( d
& F( }7 |5 j9 v" X/ u" G; e
! s' W$ C- x; L4.CSS阶梯样式边框" z% B: D1 I4 N8 f: k
CSS代码:5 M+ E- d( ]: a
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
box-shadow:
inset #0096880005px,
inset #059c8e0001px,
inset #0cab9c00010px,
inset #1fbdae00011px,
inset #8ce9ff00016px,
inset #48e4d600017px,
inset #e5f9f700021px,
inset #bfecf700022px
} 效果如下:% A3 a1 y3 }8 i
$ p/ n( H+ n9 {' h$ I# _
. P1 N+ `$ _0 }; X% p5.CSS只有阴影边框
- Y* L( M8 [- j TCSS代码:, i4 c- `, V; ]. `
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:/ j% n2 F, f/ R" P0 j( a8 n# a
9 }0 q# g/ s5 a; b& L
2 k: D. a% j" m3 v) ]5 ~1 ^ K
6.CSS带阴影和轮廓的边框
8 Q' e9 G8 |/ D; o. GCSS代码:
: K; Q" ~7 Z5 C; ]: J5 o#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
box-shadow: 00010px white;
outline: dashed 10px#009688;
} 效果如下:6 _/ m- Z- z1 Y
! C1 u2 T1 @, F; Q
" [. T- ~7 |; v* U( d, u- L7.CSS少量阴影和轮廓的边框' c% B+ U/ F+ J; E+ _, U" x
CSS代码:9 T1 [( W% D$ n, I) O6 a1 C
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
box-shadow:
0001px#009688,
0005px#F44336,
0009px#673AB7,
00010px#009688;
outline: dashed 10px#009688;
} 效果如下:
* e/ A s7 v& l+ ~9 `0 y+ V0 U
8 E' D* M q; I) c
: j6 t l2 k P1 [2 H8 U: W* Y, ^8.CSS带有阴影的双边框
! P1 Q* b+ Q+ c# w3 f, ECSS代码:' `7 Q1 b+ S: U+ H
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
box-shadow: 00010px#009688;
border: 10px solid #009688;
outline: dashed 10px white;
} 效果如下:
[: c( @4 p" x; Y4 n
$ J9 \" d+ g* e+ t" V; k9 `' D
$ K: |7 r! G' `( H6 z
9.CSS多色边框+ ]; A5 |' Y' Y' _
CSS代码:/ l8 W p9 I6 T! X: [* Z
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
background:
linear-gradient(to top, #4caf50, #4caf50 10px, transparent 10px),
linear-gradient(to right, #c1ef8c, #c1ef8c 10px, transparent 10px),
linear-gradient(to bottom, #8bc34a, #8bc34a 10px, transparent 10px),
linear-gradient(to left, #009688, #00968810px, transparent 10px);
background-origin: border-box;
} 效果如下:! i* x+ t+ k% {. U# c* m
|