CSS 样式是边框最重要的一个方面,这不是因为样式控制着边框的显示(当然,样式确实控制着边框的显示),而是因为如果没有样式,将根本没有边框。
+ B9 K) g1 j- o" o. @6 `9 I2 X 以下各特效用的HTML代码相同:
) I. `, I: L9 s% ~( `<div id="box">
编程适合那些有不同想法的人... <br/>
对于那些想要创造大事物并愿意改变世界的人们。
</div> - \: Q2 g/ ^( i I$ Q. @7 s$ ~
1. CSS动画边框
* r1 h8 }, J5 w1 [' p- w/ _CSS代码:4 e' o' {* V& l% f
@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;
} 效果如下:
2 i) B- V8 @! ~' q- E
2 {$ }5 H2 j( l1 N x2 }/ @- {% H; h+ T5 ~ z! N
2. CSS图像边框. }1 |( q+ \& D5 Q* c% G% u: f6 W
CSS代码:* d& a6 I0 o2 h( n( d2 a+ @# H8 l$ K
#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;
} 效果如下:
* v8 S# Z8 z/ M* Q) }: N$ P
+ ]9 F* a% o8 r+ l! Z$ Q
1 [" t' g. t* D
3.CSS蛇式边框1 Y* @( n9 f$ \% I4 K
CSS代码:0 H) m; W1 q6 m# S( X& M1 d/ 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;
} 效果如下:) r8 ~; O1 R! J# v( i, M, G9 Y
3 I: h- e, [7 S0 c' `5 g" f
. j% l/ ^( D' p" q
4.CSS阶梯样式边框: L: O/ q( S" J) ]& q
CSS代码:7 l+ ~* z) N2 \- 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
} 效果如下:) {6 ?, u( l' z Z' I4 Y
; Q, h# B% o) Z" c8 o0 _! Z9 v
; C( [, N* E- \: S9 Q! w; g5.CSS只有阴影边框
$ B. Q. T7 Y' HCSS代码:+ x& s) I5 t8 P" c f6 E
#box {
font-family: Arial;
font-size: 18px;
line-height: 30px;
font-weight: bold;
color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 00010px white;
} 效果如下:
6 n4 {5 K X9 M. K: e* T
- E4 ^9 {+ I3 N3 }4 Z
% r4 E! c' J) r6.CSS带阴影和轮廓的边框
1 O- ^+ d! B; a0 {! JCSS代码:& Q* C3 i/ e. |5 i, @7 R
#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;
} 效果如下:
0 M$ w: b' M3 e x2 g' E% g# T( B' e
; T$ y- f4 v( e# E1 _: `
& X* x" {: x" s9 M: Q. m
7.CSS少量阴影和轮廓的边框
! I$ D" d5 ], JCSS代码:
0 X5 h, A3 G( e$ J V( f. F#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;
} 效果如下:3 d5 d2 [6 _9 K! f( Z
% ]' |& e! l) W. y- a4 Y( a3 U, r9 D
8.CSS带有阴影的双边框0 N5 n4 @$ I8 G- D- X$ m
CSS代码:
" e* w; m* B- N! q% 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 ~5 Y1 J6 l3 p* }! z
: F9 \9 K# Q$ w" t
+ ]% G2 d% v* R8 p9 h+ W$ U/ t! h9.CSS多色边框0 [( U7 D9 ]! U. U5 O- j" @+ j _
CSS代码:
5 A/ w. s2 ]( l1 p, P# j* L#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;
} 效果如下:9 Q% E- q! ]+ a
|