CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
8 Q9 W2 ~ J9 k 以下各特效用的HTML代码相同:
3 ~- d5 \: a/ S' h4 L( d5 C5 n<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
, `! A z* L' F- r4 V1. CSS动画边框
. O! q0 `# C0 A, \1 a; P9 |CSS代码:
. d$ }* r( j& T) ]/ ?- \8 ~@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;
} 效果如下:
2 l( D$ o. U+ |. Y8 v
( z8 f2 [* s2 F+ ^ j; a; S
5 {* ]; _. s, `' c2. CSS图像边框7 J& a; @% ~: U, E, Y
CSS代码:
% j6 o# n9 F" g9 k! D#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;
} 效果如下:, F( [9 X7 k/ o1 i
# a# s( e/ e0 O5 ~" `3 N
$ _7 P7 [( j& E$ S& m% j/ s3 n7 d
3.CSS蛇式边框) O/ U" _. t6 m# d' I' Z* C3 P
CSS代码:3 A4 P0 N& M& |! A1 o- C2 O
#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;
} 效果如下:
* _! ` d! ~9 j2 K1 p
2 y" y# s7 T! B1 Y' a% T* G5 `& ~ ^& E$ u7 q7 x
4.CSS阶梯样式边框
5 y" e9 q* |5 Y C. `% q$ b: uCSS代码:- Y( I1 l% q& e: a- P9 o
#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
} 效果如下:
* o, d7 X, i' e. C+ f) O
' {. w" V% X# H) M" _! n* ?
; p8 n$ O5 {. A* v3 ^- D5 \: @
5.CSS只有阴影边框
0 s: e G1 z+ p* U+ R, L0 uCSS代码:# R* |6 [' X. E! K. A% A P
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
# \. Z; Z0 R# W! G
7 X9 g" H* b6 h0 T% G1 b" F/ C1 P
( k- X% ~, c. Z# T T6.CSS带阴影和轮廓的边框4 O# \% |# i; y: `" x
CSS代码:5 J$ Y% _+ [, I& n
#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;
} 效果如下:
! r# K, i v+ C% H' q
* A/ X" U% o+ W2 `0 e
/ _! @* H+ `9 c+ C1 O# A% Q* C7.CSS少量阴影和轮廓的边框1 }6 Y0 d" L9 h/ G9 r/ l* j
CSS代码:
0 w8 u6 D; Q- n( ^" J#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;
} 效果如下:
1 ^8 ]% @; o. ?. W B, T
0 K5 v( Y7 O9 p! B6 c1 O2 h# q
/ c0 K! u9 h9 Z4 A# e8 E8.CSS带有阴影的双边框5 {' u# _. H+ G. g1 m
CSS代码:
( j. A" d/ A: `9 D0 f6 d#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;
} 效果如下:
) A: t/ G' e% J9 f. w$ K# m" T
" f4 B% v5 v+ [5 Y4 |2 e
7 h' {# g( j% s6 I$ R9.CSS多色边框
, ?! u8 T0 w$ P* U6 Q5 pCSS代码:
* q2 t2 i" t; M) p#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;
} 效果如下:
. J j# G" }, q) X4 L: O
|