CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
/ c1 i: _$ } P; X: X1 Q! \ 以下各特效用的HTML代码相同:
0 e& Q L i9 r. y* l<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
' N+ o8 R# T2 U/ C: h: U. A0 w0 X; l1. CSS动画边框) Y7 }& z: g* q# H y0 q* i
CSS代码:% N$ q9 O$ w4 {; G. @- H
@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;
} 效果如下:$ g! ~5 q! }1 G. |3 p" z
, F7 j+ V6 [3 a$ G$ ~8 M
& |/ h% W8 r1 B: ]! d+ G3 ~# [9 K2. CSS图像边框
4 t1 b! I: Q! CCSS代码:: o3 r! |# V: F: ]. R1 d3 j2 P7 D
#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;
} 效果如下:
4 a: K. S# B9 r- x6 t- v7 M8 m8 o0 Q
. q* S; R/ X, E; |% v. D
. S e% p2 _/ N2 i" k! z
3.CSS蛇式边框: x8 H$ a Z1 f% q3 C/ S7 Z
CSS代码:% y0 b- a, u$ i" S
#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- M6 `) ^& ]! s- _; V
% L9 _1 Y5 e, E) a4 J$ f; C
- M& |$ V8 ]' f6 H4.CSS阶梯样式边框( ?. ?4 m% _4 d8 C( n/ U$ e7 J
CSS代码:% \2 j- {& K* d4 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
} 效果如下:
$ F+ n7 \. @8 T- A* o0 \" \
1 L" K8 J% O" d- I# t) |8 p( k+ j( \2 g2 v9 b: n+ O8 m
5.CSS只有阴影边框2 u* U8 I- |; x I$ Y/ w k) p, j
CSS代码:
2 w% X/ z6 H8 u Y# @ h0 H) Y9 [#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
, S+ @& v+ |' b1 {1 R- X; m, ?
! K8 V5 n" y3 E8 z0 ]4 D5 G I# B% c+ C) n- G3 `
6.CSS带阴影和轮廓的边框2 s' H$ h p0 `5 S& a! @. f
CSS代码:
0 m- s4 S9 K! O+ @7 n0 D#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;
} 效果如下:
( u1 u# b1 V- w* }) U8 `
( C& a: ?1 ?; m* b6 v
: z f1 F+ V) y# M% R5 }7.CSS少量阴影和轮廓的边框( ?% h$ p0 \/ o
CSS代码:
9 t0 }( V9 d2 Z( u5 z1 ?( v, W2 ]! l#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;
} 效果如下:
/ e( H, L7 I; p/ `2 I
% W8 X# X! I. K) q2 g+ o
1 E& {% p) m4 E4 i% V' P
8.CSS带有阴影的双边框
- d' d* ` A, j! p* [CSS代码:! j% f2 w/ d* b) i5 G) G
#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;
} 效果如下:; @5 a6 O7 V: Z/ G9 v( T* T
/ P0 X6 i5 n3 d/ M; Y2 R3 m
. G. Q4 B% I9 q/ W' p9 ~! n; m L( V9.CSS多色边框) w; \7 k: K. j7 b
CSS代码:
9 l* l# _3 ~( I7 x 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;
} 效果如下:
6 A- T- C6 n% F4 Q6 ?5 t6 u
|