CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
7 I! P8 G8 n1 u6 B$ \ 以下各特效用的HTML代码相同:6 L8 {* x; n$ N J
<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div>
9 U7 x: h% f+ h/ E1. CSS动画边框
U4 O! }3 s, b5 _! \CSS代码:
* r3 C. J4 z5 ?- q* m* X% F6 N( p@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;
} 效果如下:3 O1 Y/ M- M- x6 ?, ~& |8 F$ ]8 B0 L
' m. ?* _8 f* B0 ?* |' S7 j( X- `
' l, @9 G" ^ l2. CSS图像边框8 R2 |3 D7 N6 u; f3 Q$ b `
CSS代码:4 x# I/ @2 |' W$ W9 s4 @& T
#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;
} 效果如下:, q% h9 Y; ^; F& y- ^. a( O) ?! w
# X# Z/ z3 H: C( B4 g0 w; j. P8 J. [6 }4 s. N
3.CSS蛇式边框$ T9 P' Y" a9 v8 ]" M, y
CSS代码:4 d4 f" }8 N2 _) r2 t5 X
#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;
} 效果如下:8 M& u; h6 K( C4 g. G. b9 i
3 Z9 z6 u A: {: Q C
e' P( H4 M; Y8 z J1 G' ~- Q- T4 l4.CSS阶梯样式边框 O7 L9 y4 }3 c$ X
CSS代码:/ Q( y+ t- R) W3 ^# \/ }8 l4 a% W% j
#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 t+ [ P+ Z/ v2 c4 ?/ ^( y
: E9 M# {* u+ l y, ~5 B
: L8 I3 M7 s4 e7 H
5.CSS只有阴影边框
6 K. D# p! U8 Y0 a& MCSS代码:
" A2 z0 G5 |' 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;
} 效果如下:, |5 ]1 @9 U) I- I/ }. A
8 Z" u8 v7 i& [
7 K4 d& w- {/ [% U- t& I. s' d
6.CSS带阴影和轮廓的边框2 m4 ]: f# t% d! ]/ d
CSS代码:( b- v" S0 _# Y" O$ G
#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;
} 效果如下:. Y. B1 Y8 S+ |
6 @) u, u8 j, X/ `2 L/ c
- B4 q- F/ _. \, ]3 Z, e! X4 f7.CSS少量阴影和轮廓的边框- k* C! t; c% h
CSS代码:8 Q; }* Z: O* L( c! y
#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;
} 效果如下:- u, G [% D( z O5 }% F7 ]" Q
3 C. Y4 `/ C) ^" K( R3 Q4 N5 F
, w2 K/ W7 f' }& u0 b9 L: F8.CSS带有阴影的双边框
* N+ t4 g, u0 M I: T* \# ^* iCSS代码:
( c& r4 R% a& E4 p. ~' O" Z e#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;
} 效果如下:
4 f/ s; K4 z! [* x4 T
3 j; s. y3 p4 N% `# I3 U4 i3 S, ^0 [# p
9.CSS多色边框( y3 \( p `2 ^. x- E
CSS代码:
2 M2 c% Z; y; v7 m3 }9 I1 ^#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 s7 ?, n6 K) n; T* z: \# k4 ^
|