CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
& t4 Q; P/ z# F9 Z 以下各特效用的HTML代码相同:
. r+ Y+ }5 V0 r<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
2 r9 o3 ~ r# b! u' \- x3 C# g1. CSS动画边框+ {" o0 P; q" S( Y
CSS代码:# A% x9 H/ D8 i( h' j+ N) f4 o
@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;
} 效果如下:& M+ y7 r3 R6 `) ?% w
' }1 W# s1 ^* o. v* q8 v% V! Y5 O" z% d8 N7 p" L) {# i
2. CSS图像边框
+ t" ]# \6 c3 w) X& B" v0 \1 oCSS代码:. A1 T% ^. `# s% K( F" C4 A
#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;
} 效果如下:
- m1 Q* }2 }' R& x
7 b( f. C; a+ Z/ p8 l
* l6 }3 r* e4 c6 ~ k/ ~3 g9 U3.CSS蛇式边框
& [, b# t, @% }3 dCSS代码:! Z% R# m6 j$ P' E6 U
#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;
} 效果如下:
+ G7 J) Z) E& Z0 K* v; L
7 A+ J- B7 T. l% o% ~
# w7 G" K, l" z$ _2 E9 `4.CSS阶梯样式边框
- _% `; |& i! T. A" T- h9 ?CSS代码:
' P$ Y6 G8 t* l% I+ k! P) l#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
} 效果如下:/ ?( v5 d! a( Z
5 v7 n* w; J4 d( Z# a& x9 t$ j
2 o. a; X5 C/ h9 _5.CSS只有阴影边框
; \+ j5 I2 e" G H, LCSS代码:
0 T9 n) g" O* t1 I4 M3 j* R#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:: _: c, _9 A( i# g& Z/ ?( ^/ V
/ [; Q! f) W4 x$ I4 U# |' b
" h, ^0 O- r4 |" y. G$ r. f1 \6.CSS带阴影和轮廓的边框
7 U* A, N8 s. e2 K0 {CSS代码:1 J* Z) u; c3 v) C/ p0 V3 L! J7 b
#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;
} 效果如下:
( U& b$ f/ _8 q1 }; l) J0 ]
' j7 A/ W- r, J& n
; g7 a! a9 ^1 w X) d1 A
7.CSS少量阴影和轮廓的边框6 d: w$ y; p; j
CSS代码:
1 h2 E4 M; O4 H5 H+ P I#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;
} 效果如下:
( D V6 V3 @- z5 D0 ~0 D
& A- U1 ~7 O' }$ K9 s+ q
8 ^$ q" D( `( H8 \5 z+ q- G5 [: E8.CSS带有阴影的双边框( z; l H" K8 \) i: z" }
CSS代码:
& P2 s) t3 K) A c6 ]. l9 n#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;
} 效果如下:: U P# r8 M- n' _ |# \! U
7 L I9 c/ t1 {- B7 m! L2 |2 i/ w; z& ?. r$ O
9.CSS多色边框
8 ^9 ]/ l' ^ g; WCSS代码:* F7 X. B- f: p3 B W8 E7 _9 w
#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;
} 效果如下:: ^& x k5 O% u* }
|