CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
2 h, l1 W Y) i 以下各特效用的HTML代码相同:
; c( @: [ n. C/ e/ E; n4 b+ e<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
* o' _" y6 U* S; f1. CSS动画边框3 S/ n7 P4 t) I
CSS代码:2 N( i7 Q7 M- C% @" B" C
@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;
} 效果如下:9 r6 t$ L& N8 a
# G4 w9 m1 B- |
" w% Z' Q+ E' G: k) A! U8 u- f2. CSS图像边框, G+ w+ F/ o' c- W: a" ~
CSS代码:
( ^( l. r0 i7 w- h% e2 i% G2 v#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;
} 效果如下:0 W4 A/ a( _% v' y4 K
1 ? m3 L. V! g ]9 \/ d' F" \8 K5 k4 F0 Z( c% M% W
3.CSS蛇式边框. D8 ?6 x f: \0 K; O
CSS代码:: q* ~! G/ F, R6 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;
} 效果如下:( ]& A4 s8 A9 ^9 Y( `; X7 O5 ^, @2 i
6 D' `/ { O. B; c; m; E" V( Y$ |! @; G4 w
4.CSS阶梯样式边框# y" k% Z$ a- Y9 F* ?2 o- s
CSS代码:
1 z: E; \, H! ^7 [1 ~9 o, M#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
} 效果如下:
# l* ?; w, Z" A* Q Q1 r0 q6 A
: w* A* ]: e# v5 V$ u
7 j& @$ {! l$ y7 F* N5.CSS只有阴影边框 P. s3 ]8 i* s
CSS代码:9 J, I3 N. m6 U! t2 L
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
, n- P4 o3 z5 n
. r: e) j0 k) R" J9 v
5 [: @. Z g: m6.CSS带阴影和轮廓的边框
+ G) a1 Q8 \; j; Z$ DCSS代码:
9 l3 K( q$ ?& u. a#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;
} 效果如下:
( ~4 G0 @3 w- u! n+ p& O+ G
& d- S$ R, C3 M& H! `; v
3 s9 a8 y K4 ?+ T7.CSS少量阴影和轮廓的边框
0 d9 ~, C' I# U9 E: ^8 l& @- A1 cCSS代码:5 b: N$ p( v O0 {
#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;
} 效果如下:% u3 K, ]) O8 c
b' m) Q. Z4 ^) w
& [3 n$ I( [& P3 [8.CSS带有阴影的双边框
H8 ^# q: i( ?( ?% R7 ?% C3 vCSS代码:
* F! \! w# u6 T, ~8 b#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;
} 效果如下:/ _: x+ Y- w c# ]/ w
9 d B6 R' l9 X' V0 B, e# g. \3 K
- i( L3 X, U; ?( ~
9.CSS多色边框# O/ T) q7 T' o' t
CSS代码:; O7 h( ~7 a4 L# ?& Q/ ]" W4 A7 q
#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;
} 效果如下:8 F2 x7 L4 d4 e5 e9 n% x
|