CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
/ C9 \# Q3 x0 A! a 以下各特效用的HTML代码相同:
# o1 {8 C) b9 ~; F; t6 M, H2 a4 ^<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
. g7 v# E: Y1 a" r; M1. CSS动画边框1 B# m% Z) x2 F
CSS代码:7 q& H4 W# ?! K. D. ~$ ~9 A
@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;
} 效果如下:1 [4 L2 L |$ t5 u6 T/ a! \3 h5 q! \
: k' z5 k" y7 p5 T$ _- k1 l
9 b: z: u4 Z" _: t0 L
2. CSS图像边框2 Q5 i/ j9 w2 Z3 b6 O6 z6 ]
CSS代码:
' ~3 }1 @/ N5 q& g9 z/ b6 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;
} 效果如下:, ^2 x1 B% u0 \2 I( n
$ r7 a# K( a, G' z7 x" V
/ J+ \) z, {' F( a" N8 n7 [( H2 a
3.CSS蛇式边框/ o0 N, q. f' V+ r
CSS代码:- M9 g2 s0 D+ j9 P
#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;
} 效果如下:
5 f; S5 O0 A R: e u/ }
0 ]9 S. a ?! [- K& N7 q$ I% D3 ~# O7 {- T+ c! ]
4.CSS阶梯样式边框: u3 f# F6 R) s$ z
CSS代码:% k& k& N7 P5 o+ s' P9 V
#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
} 效果如下:. J1 S1 v1 [( f$ u3 J+ m
! ~ w6 b% a2 V1 a% V+ t6 {
7 }5 ]0 K5 s$ y/ l5.CSS只有阴影边框
: A" q. ~, j# e9 T# R4 C; E% ECSS代码:
* |7 T! y0 O' W2 H, x' S; 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;
} 效果如下:
6 R0 L8 Y' n; t
* f. x) |, A# h( u4 [
8 T' |% r$ z9 v/ Z" I6.CSS带阴影和轮廓的边框
9 @3 v) J% }% p" a: d# V6 U$ KCSS代码:
S' n+ r; r: ~ u6 T#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;
} 效果如下:$ C6 d$ T$ o% F2 R
7 }% b3 ], j4 c! `) E D
6 v% t0 Y2 H3 g- ^- r! a' ]7.CSS少量阴影和轮廓的边框
+ P5 d! j2 D& YCSS代码:
5 l& N8 {' y+ o/ G4 {6 L2 I6 n#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;
} 效果如下:5 J- X# ^2 o5 F8 i& @% ~% ]/ n
; L; _, h; [$ o) p7 }# ^, @
6 ?4 Y8 w7 l V" W \# Y
8.CSS带有阴影的双边框0 }2 S% r$ A; k3 J3 ]
CSS代码:
6 r' `) }3 Y6 i8 Z#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;
} 效果如下:$ F" j. w2 i% f& V2 u! |9 u2 \3 |
. @1 Q4 P5 t g; F# s
% a1 \9 Q( t6 q- V, C/ a
9.CSS多色边框) f9 Y3 U9 q& A# K7 O+ x7 f
CSS代码:
+ m( p: f, K" Y! f- B2 l1 ?3 Z n#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;
} 效果如下:
3 J) m% W. t# g6 }% h+ b. N# {
|