CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
& r. R3 l2 c/ n5 v 以下各特效用的HTML代码相同:
! x9 H7 o7 V) Q4 W<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
1 `4 ~. @" F6 U: v) D+ O1 T1. CSS动画边框: @; c3 a+ a8 q& }2 v [5 |
CSS代码:
7 [! h" |2 J2 j- v& ]3 w; A. 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;
} 效果如下:) C2 Q8 [+ u3 K7 D. I4 s& H
% Z: ~- w( g% z, X+ m
0 b! @) t4 c* L; q2 p
2. CSS图像边框2 s$ R3 |3 c; l$ v
CSS代码:8 E- H( u) F$ N+ t6 }3 a% a8 }
#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;
} 效果如下:
6 i$ g; e5 H* `! R! [0 P; q* v7 Y O
% n' r0 o. p0 Y3 V, A
3 v |7 e" ^' C6 @4 T3.CSS蛇式边框
( M r" L x2 fCSS代码:# s! g% {( Q; d7 y
#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;
} 效果如下:* f* l [2 E* M, R6 Y$ O
& d4 U N- A6 i. z, {; w& a m' e
) j4 T; M# A1 W' Q7 t4.CSS阶梯样式边框1 l/ m+ |' e; k9 h; m
CSS代码:
8 ^7 X3 N" c/ E. d* b! T$ S% a1 G#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
} 效果如下:/ x8 p* K! g: }9 m0 ?
7 p0 c8 N$ {- b4 @) G& t- J
- ?+ ?+ Q g' D1 X P S
5.CSS只有阴影边框. ~& B5 {' ?& R+ ]4 i5 j( W
CSS代码:) ^* N r, Z/ i5 |- ]) V Z
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:3 E* G* Q1 Y5 t8 T2 ] q7 j+ A
+ s+ d/ `) m. @( f! J4 u2 B/ G, ]0 t+ O
6.CSS带阴影和轮廓的边框7 z4 @) e: L* A
CSS代码:" `+ z' x, u. ^' H0 J3 r0 F) ?5 X
#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;
} 效果如下:
( K2 q% F: K/ p6 ?4 _
7 P) ^3 p( i# L9 E) g0 L/ x6 F& r% z: ~& M1 V u
7.CSS少量阴影和轮廓的边框& _: C; U( E6 S* h6 B' F S" I
CSS代码:
- N d H; D/ a+ u; L, e5 R" Z#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;
} 效果如下:
$ ]/ }2 @5 h/ r& P4 s
9 ~! K7 b8 x! i5 [7 B% @
! S2 x: C$ H0 p- k5 C
8.CSS带有阴影的双边框
! K0 Q' k2 x. j3 QCSS代码:( C% B: U$ r3 H* T& R* `; x8 Q$ `7 ^
#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;
} 效果如下:$ w% p6 U" {3 o( k, ~* u5 N* X; w
: b) I; q; e4 u& k" \& [
! O+ F1 d( G% J* Z, O; O5 W9.CSS多色边框
$ i* C+ E- b. s; y$ u& yCSS代码:
# {4 l4 I$ w. T5 Y, v; p8 Y#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;
} 效果如下:: F+ O5 v7 Z& r. t2 |
|