CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
. S3 l. N7 O$ W E, W 以下各特效用的HTML代码相同:
& G; s1 M$ l! z# Q<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
+ y1 F0 \9 }8 K8 m Q* }0 h1. CSS动画边框
( [- s) y4 C3 n. m% k6 l5 `CSS代码:2 Q$ r- F$ Z' O
@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;
} 效果如下:/ b6 f- y2 T" F9 P; ~
3 W* W# m/ N* h3 O7 t: ^
' U* r( x( {* c& o1 {2 w2. CSS图像边框
K) e& i( I' [" c7 m8 n8 Y% ]CSS代码:
0 K' Q1 P' w f! y; S) x% y#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;
} 效果如下:
6 j# d O- K- C. Y! [
6 `" x# m* F5 m$ {+ r8 f5 [. a# V; H* e, n/ k0 y0 z+ G
3.CSS蛇式边框
3 s( h5 p$ @" x; oCSS代码:2 |6 I) H: ?6 u9 H, H1 E
#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;
} 效果如下:
+ l g1 o* ^1 n4 s; a
0 H' |6 i) N: E+ o* }& X0 _
$ O: O8 x9 T5 B) B# _' @
4.CSS阶梯样式边框 N8 N! c" \% r
CSS代码:, S. R, f5 c( x' 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
} 效果如下:
! `! _: n( h. `+ @: g5 L
1 @$ b8 G8 ^4 I0 e) i- `4 D2 t5 Y+ q v# k+ u
5.CSS只有阴影边框! {3 r) Z c7 i. Y# c$ }
CSS代码:
9 o+ m, |! |. h+ P6 y: n#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:5 P1 S3 j$ ^0 a1 j7 g
, o/ m/ f6 ?8 E: k$ X. Q8 P
3 E, J V7 }8 j [6.CSS带阴影和轮廓的边框
1 T& ^* E" v5 y% Y% Z/ _1 Q# E. RCSS代码:
Q W0 i8 t! u) X#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;
} 效果如下:
; w1 J2 e+ B' s4 u
! U) e, h4 d, U6 i( A, o; Q2 u
: D# A# p3 V" L# e% K4 D7.CSS少量阴影和轮廓的边框
2 H% z5 R' T$ T- @4 ^! sCSS代码:
% J$ W# X) U5 Z0 P5 [+ G#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;
} 效果如下:
& H- ?7 R4 @1 n
( Z" q5 [ y. U, s3 |. h
# [; M6 ~; J/ J8 [% {0 D8.CSS带有阴影的双边框5 b9 O" H2 T: z/ M
CSS代码:9 ?1 M0 k* ^- I9 {8 Y' [4 ^
#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;
} 效果如下:, u* t' e$ O4 a9 ]
/ ?! g. N; p( ^2 `1 p4 @5 @7 M1 l8 n3 [' ^" F! ]
9.CSS多色边框& D0 \1 J2 g- B
CSS代码:
7 x' V8 `* I! P#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;
} 效果如下:+ c1 _) N# ?3 B9 K+ X8 k1 {
|