CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
2 a( B& C/ M/ X) i+ D# J 以下各特效用的HTML代码相同:
. C- U3 U% b) @7 U; u<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
9 s4 n1 v7 D! p% E- F& ^2 N1. CSS动画边框* O. \7 C0 R- O( ?' J
CSS代码:; t1 y! l- X/ @) _2 n/ K
@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;
} 效果如下:: p, O9 J2 P9 j5 q; a5 F1 N
1 A1 k0 `) q0 \: f: R# m
" P! _- B" i4 W2. CSS图像边框- ]: o p7 i- b0 i
CSS代码:
1 H. r; h$ s! a1 Q#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;
} 效果如下:
3 u1 ]0 J" l9 Y' h
" u2 M/ k8 I* M3 p1 R, s
' ? d% J- r1 E* M3.CSS蛇式边框
. ?2 K1 i3 `# W) L, E! ICSS代码:
3 p. T. D" P, d+ 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;
} 效果如下:$ i! l1 p) ~0 v1 s1 u
- z+ K5 k, M! S
2 I# z9 S% W6 W# z% @+ D: W! P4.CSS阶梯样式边框
' x G/ Q( K$ o F8 n R! e: yCSS代码:) k- X7 o8 N1 f' N
#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
} 效果如下:
9 c! J# @* a3 [9 Q
5 O2 ?1 B: R/ w0 C% Z
$ a" J& h P" L) E5 I$ N
5.CSS只有阴影边框3 g5 u% s2 C$ h( z0 A4 U* {- q1 M
CSS代码:" x0 u0 ~) n% j1 j
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:' R( c& d+ [0 g5 f" x
, a% r% X# s! d
8 Y. Q( a! Z# i% i. \$ R6.CSS带阴影和轮廓的边框
4 ]2 W0 l x9 \. RCSS代码:/ U" J( X1 s2 G7 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;
} 效果如下:6 h" {) \0 ? c r2 [
5 j* ?. m# i5 s; \
5 @6 k% H) Q1 S( x4 b* a& t! \7.CSS少量阴影和轮廓的边框
" i9 D! l7 P; U9 o( i# D) M3 w- qCSS代码:
" ?6 e/ R' z& }8 @#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;
} 效果如下:: s- u: R" W }
. B! f# N$ N0 _) ?* n- o% D( k8 w3 q- G& V! u
8.CSS带有阴影的双边框, J* c0 v+ g9 Y+ m% ^6 r0 l
CSS代码:
M! u( i# }5 F7 t6 p#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;
} 效果如下:
i, {# \- B2 m4 l1 k$ C
( u5 h% J! A/ y! L6 I, N3 j" C, M+ L2 L: }, V
9.CSS多色边框
' O# ]% o2 S1 mCSS代码:* h# E+ |& H* o, Q$ }& U
#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;
} 效果如下:- L7 {9 i$ L' M0 I
|