CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
! w n* s- _% y" _3 \8 O4 F 以下各特效用的HTML代码相同:6 ]$ t( [) F* Z2 B6 m# K
<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div> $ `6 D( o. z, [# ]
1. CSS动画边框" H1 H, q$ ?' @1 d) S% j1 ]' B* }: W/ f
CSS代码:. {& e9 s6 {8 b* n
@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;
} 效果如下:
" o7 M1 e1 }) }, K% X: s
0 B9 y4 o0 M. \) d& E
* r6 i. ~: b) X+ f) R+ n# r5 q: u& y2. CSS图像边框/ c" g& O/ Y; q) E6 L. a
CSS代码:
" b5 G! n2 z) w( H: L#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;
} 效果如下:
8 R9 x8 j" ]+ `7 E2 X
, b- w6 P7 B# j+ t$ K4 X0 r" V
3.CSS蛇式边框2 f' Z1 H# v. T3 U0 ]
CSS代码:
% B. L! _2 k5 k% D6 e$ p. q#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;
} 效果如下:! Q" g5 V/ W, M; A; z+ b
1 I( V' p: ]/ k. ~: n
3 u0 C9 ]) K. U8 ^- V' V
4.CSS阶梯样式边框% T' L9 ^* u/ i/ {# p G* a; g
CSS代码:
9 z) y" k0 t# _! Y- ]; z#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
} 效果如下:
0 \ B1 S3 v' N/ ]3 U
/ G! ~9 X0 v, {" B& Z) u
9 K# {4 |& D2 d9 v
5.CSS只有阴影边框
: Y5 M5 P6 o% `) g: W0 O! ZCSS代码:* a, G8 I6 e) R+ x
#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 T9 ]0 K/ N- ^: W
. E9 S% G" ]# c% }' f$ [) [( i5 Z" s8 r
6.CSS带阴影和轮廓的边框
8 }( P* m/ S( {5 wCSS代码:
5 d4 a" L0 A4 A" K. {9 S#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;
} 效果如下:
- {2 U1 l0 X) S. B" f0 q
?: E l, f- b
1 f! ]! x! f) q: K4 U y
7.CSS少量阴影和轮廓的边框
8 e* y) K/ R' t+ i# E5 A# @- Q; oCSS代码:
7 h5 N# G( [* o#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;
} 效果如下:
4 M, t0 G% f& r, B
) q J( N6 z0 y: s4 L- `/ r8 n' T i O+ B! a0 o# v
8.CSS带有阴影的双边框3 o% E, e4 P6 e: V, o; U
CSS代码:5 k. R9 q: T6 b) w$ ~- f0 J6 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;
} 效果如下:0 A, q; f; L2 [" P8 [6 e
: n" X* J, E1 e' | t! D
/ `! a4 P: L9 _2 D4 Y) j9.CSS多色边框& _5 Z5 Y+ F" \
CSS代码:
: w. y* Y$ X5 O#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;
} 效果如下:
5 h; O) L, I0 h8 l- I* Q
|