CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
( T8 a/ a7 O p$ D, o6 C 以下各特效用的HTML代码相同:: {. d+ R9 X% L# o' |6 A
<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
! _' W9 v b; @* N+ w% D1. CSS动画边框" \; L+ l) q8 f! ?9 d! l; S
CSS代码:
4 D# m; W. a4 w+ v7 S@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;
} 效果如下:8 O4 D: N1 x) H. T+ m% X
6 ?1 e8 p. r _* X$ ]/ \
4 N, S/ ?$ h0 j2. CSS图像边框: E" T! m' Z+ r) Y4 g! r3 m4 D
CSS代码:: Y* U9 Q; f% M5 r n+ {
#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;
} 效果如下:; Y1 i6 n- `3 b, j- H- i
6 I( M- F# N! J) _. n, M
( v% F% `$ t% i/ @( {4 V. G3.CSS蛇式边框
- Y( ]. H& A4 o F. {+ ^1 X3 CCSS代码:
+ `' g; L5 S) P$ F& A/ ]#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;
} 效果如下:) s ~& d9 ~; G7 |) X* Y5 n2 l4 Y
3 S4 L8 W$ q0 q0 D2 W5 J7 j7 |( D' C8 Y: V q
4.CSS阶梯样式边框
& x# A: E7 Z# a( N5 Q) rCSS代码:
! b0 j' T# ]% |: @ k- f#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
} 效果如下: ]3 {# [6 c. o
& }( C8 ^2 a+ W: N8 M; g: G2 D6 G0 Y
: E3 k! j5 E9 q$ e5.CSS只有阴影边框
7 x+ q; v# u; ?( ^4 f: T' p3 \CSS代码:
% j. Y8 Z# @7 N0 K. R, m Y; @, U K#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
* F+ ~% i! o7 `
. b: q& ], h. d$ v: |& K3 v( F
3 u6 U; @" R- B. j9 B" O$ [/ l: @
6.CSS带阴影和轮廓的边框# @9 N# ~& i* f
CSS代码:; J& X7 T! o6 e7 Z5 w- w
#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;
} 效果如下:
8 x, F/ [* L6 n
8 l) ?$ d. H/ v5 O
% T0 z7 L7 ~5 O3 R3 H0 V* D7.CSS少量阴影和轮廓的边框, g: l) d# A( e- V% Y
CSS代码:/ Z* v4 _$ N9 O7 `# D4 ]
#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;
} 效果如下:0 \) I" d1 H3 `1 ~
: G4 m; A9 ]. o9 Z8 \, f7 Q- O9 |1 j6 N8 ^2 I
8.CSS带有阴影的双边框) S r9 p) ?5 z, Y6 I! T! Q
CSS代码:6 `$ j1 G- @0 D6 M: c7 @
#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;
} 效果如下:' z! c, {: `; I1 y1 ]8 c4 k
' n$ V6 u8 L% j+ p6 }2 U: M: b+ J1 l
9.CSS多色边框
2 J9 h( m% k& B2 G1 a( MCSS代码:" ~8 P9 {+ C& L3 ^/ j9 G
#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;
} 效果如下:
( t: Y* O: w5 r }) K
|