CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。' R7 i8 W5 ]3 J7 |+ s( P
以下各特效用的HTML代码相同:* x( G, A W0 Y6 U) A9 L% E
<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
1 H! a! n9 U \* y' v& r3 S+ H" K1. CSS动画边框* q* W, H. W1 k
CSS代码:. ]' _, k" T. W" u
@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;
} 效果如下:! U' T/ d- |) N- u6 E0 O4 a
$ R% H- `# r1 X& W2 s
V1 V* L ~- H
2. CSS图像边框" K+ h* N! O0 |
CSS代码:
6 E, s6 G6 c+ i1 P#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;
} 效果如下:+ r9 t( b" r) X0 N/ K
5 p; q1 H+ Q9 n% ]% V
' l6 j" \4 i; }( K% m3.CSS蛇式边框: k1 q7 y1 D- _# t
CSS代码:# H/ g' k) R' J& N9 w
#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;
} 效果如下:
7 O$ Q, a; h r7 B
0 g: P1 {" W ?
2 Y1 x0 }8 I3 R* q# ?
4.CSS阶梯样式边框
( r+ f* ^2 N) u# QCSS代码:( L/ L9 \" @* k3 q, p
#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
} 效果如下:
& G1 L2 U( G1 p
i6 ]# {: ]/ q( r1 ^! {6 W0 H$ c! W! O d
5.CSS只有阴影边框
6 v* A" b$ C6 _6 M: L) A" NCSS代码:, a6 w2 M3 U* `( q4 b2 B
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
( h' n% d# ?8 K. K
1 c7 D# i6 [/ \# `5 ^% V6 T( g- [" }
6.CSS带阴影和轮廓的边框
n: N& v% I- w9 w, _7 i- FCSS代码:; W0 @" D" r5 n H3 L4 _5 F
#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;
} 效果如下:
3 B$ X W' }8 X' q8 |
2 ^1 h: T0 O- \) _/ i2 e: N; o! c5 \9 D' V5 K2 j
7.CSS少量阴影和轮廓的边框
2 a) ^2 I d( E2 iCSS代码:
6 }% W) w! Y7 s$ r$ a# 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;
} 效果如下:
) K. r) d6 b9 |
+ B. y% u1 E$ [+ G
6 D/ _. b5 s+ e q) V: Z
8.CSS带有阴影的双边框
! S7 s. a) A/ |CSS代码:' R4 `; |9 z9 c
#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;
} 效果如下:
/ O6 H" `0 [; b# i" ~& b. p
5 b) S6 a X' V3 Y
* O/ X) [8 o* F, O; U
9.CSS多色边框1 u! q% H- H- Y( k! J
CSS代码:! p, o2 |' k; ]$ R" G4 a
#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;
} 效果如下:; z+ @4 L0 Q/ k7 J% R
|