CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
4 u8 k7 S- _& r! Q/ v! k% j+ @ 以下各特效用的HTML代码相同:" t+ G. B! u# B+ y+ i# k
<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
& a3 ~4 t. b8 P( U1 v7 S9 K1. CSS动画边框# G8 M4 e6 {8 f1 q0 Z
CSS代码:8 z3 J0 v0 b0 Q% V7 ]
@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;
} 效果如下: V6 ?* y* i0 a% h, R% Z* c
8 d+ Q8 F6 r) l' j( H2 U8 h5 O H
& L; Y9 M/ W9 f& m2. CSS图像边框) d; @: U( h+ \
CSS代码:
' Z. w: p' R( y8 w8 z! T) f) G#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;
} 效果如下:
C+ L. Q2 ?" u
?3 _* }" g; P! a
( m/ _6 ?: O( H( ]" `6 j( `
3.CSS蛇式边框- e7 \8 S2 h. m% y
CSS代码:
+ D: ?4 o1 a; j! ~4 G0 f; ]& r#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;
} 效果如下:
+ E6 F6 t: C4 H6 e0 M3 c& K
. ?" c. _) C% w& n: J" i% U$ @5 f% b4 H" U( p
4.CSS阶梯样式边框" v, S* E5 z; k" K1 ^
CSS代码:
- U! F$ G" S8 `7 O: f#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
} 效果如下:( m9 C* _& I* {! q, j4 r; J" Z
4 n* c4 \1 A1 C. z+ g
' W, C4 s* D! D' Q( T5.CSS只有阴影边框" ~$ r5 m7 s) m
CSS代码: Z5 j6 L! ?8 i0 H, w
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
4 V$ ~( _( j# X
$ N {% ?0 M8 f
" f/ L+ v x9 S$ M6.CSS带阴影和轮廓的边框
% i; N: W8 i5 m% FCSS代码:& X8 f/ V5 b& [6 q2 U5 B7 O5 h2 N& 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;
} 效果如下:
& {( H; P/ S1 B$ V& q0 s: ^- |
: S& T L% r( a2 x3 p" G6 ~
# g& F2 i7 e2 @, b- s7.CSS少量阴影和轮廓的边框# z& f7 q8 H v4 d" C5 g* ?# Z
CSS代码:0 p! h3 e, Q f! `+ F* a
#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;
} 效果如下:
8 A, a) g; P1 P% `: ?
. c, J2 ]/ Z& F& e& n3 } Z- w) f
8 o7 x8 Z- N6 x0 I8.CSS带有阴影的双边框 X, G/ x& P# e& O. ?
CSS代码:7 L3 }. D: j, Q, U
#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;
} 效果如下:6 x5 X( O) A: v
6 z5 c9 M, J4 K
/ O8 j6 [; [( ?0 h7 N+ ]$ g9.CSS多色边框
5 L+ V# T* v2 \; s5 oCSS代码:
6 y# y: W7 i, R) s0 j& ~#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;
} 效果如下:
9 X3 B0 T. x T0 o# L: e6 o
|