CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
! j% k3 V/ P: H8 H, n# _2 F' l; ~ 以下各特效用的HTML代码相同:
3 M* E6 y' Q9 x' \7 N* Y4 c<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
. h* c, T2 \0 Y& i) X& H1. CSS动画边框* ^/ B% t. ^: E, O1 D5 @) d
CSS代码:, r @0 ^2 u+ q% R
@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;
} 效果如下:( |' N4 |: B/ `
$ m7 T6 |. X v+ V1 w0 t" B! B# J
: C j' F2 b$ v2. CSS图像边框& t* P; _6 H! X" A; r! @
CSS代码:0 p I3 Q$ G: I. T* A. O& [7 V( ~8 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;
} 效果如下:
: v1 `( Y, C9 C( X+ U
; S% O+ J% ~# o4 z/ q
7 E; Q9 R- G. P0 h, y3.CSS蛇式边框) |% r) e, R2 x, T6 }
CSS代码:
, }2 Q& t7 J" W& ^" H |#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;
} 效果如下:2 Z9 P+ W& V" r( C) H
3 W& [+ D s4 {2 _7 @: n1 s& H
& r( Y: ]0 z7 D" e% ]" t6 S: M4.CSS阶梯样式边框6 X/ R: j& _/ Y# k) n5 D" ~
CSS代码:! m: |3 B k6 d& C8 K; V
#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
} 效果如下:
7 Y9 e1 Z0 p: }: w) B1 V( {( v% J; \ G
, f$ ^: X3 v9 N" B: H- G
: F0 d: o+ Q n1 M, M2 i' E5.CSS只有阴影边框( V8 J# Y. k3 S$ ] g! r0 d
CSS代码:# K s+ b& Q1 F4 f* {7 C
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
. S3 x1 \' l* X: |1 W
( I/ W2 l. J' w. O4 @
1 u. A) a+ j. I6 H/ G
6.CSS带阴影和轮廓的边框
. W8 W- @. q$ ZCSS代码:9 b; G. F$ u* x2 k
#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;
} 效果如下:
; e, o$ [& v" |" j- x. v
5 }; t6 T% p' O# @# i$ l J' [( P0 K8 ?, m* k9 w7 I, }
7.CSS少量阴影和轮廓的边框! R8 f" o4 s- W$ f( ?
CSS代码:
( D9 |, w+ P2 s3 _#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;
} 效果如下:
j4 U$ q, ^4 _0 M! x. u! A: E8 u
- t3 [, T7 S1 ~/ B' w7 f
) H H" T5 c, g" u" U" C8.CSS带有阴影的双边框& L+ j# M* h; X
CSS代码:
( ~0 f* T/ @: @6 V$ V, R#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;
} 效果如下:2 U% `6 n F, S2 b6 K0 F
" W0 L1 p$ i5 [+ M1 a# q2 z
7 o, U9 E3 j8 p) Y# o$ q9.CSS多色边框, I8 s3 ]+ g$ `! w" C# s5 L0 n
CSS代码:
# C J" k( K7 E) V! `#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;
} 效果如下: c/ e$ l& k9 c) G- _5 ?
|