CSS 日常练习----border-image

记录日常 CSS 练习的小知识点 —— border-image

border-image

点击预览

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.bi1{
width: 100px;
height: 100px;
border: 40px solid transparent;
border-image-source: url("https://mdn.mozillademos.org/files/4127/border.png") ;
/*相当于slice:100%*/
}
.bi2{
width: 100px;
height: 100px;
border: 40px solid transparent;
border-image-source: url("https://mdn.mozillademos.org/files/4127/border.png") ;
border-image-slice: 30 fill;
margin-top: 10px;
}
.bi3{
width: 100px;
height: 100px;
border: 40px solid transparent;
border-image-source: url("https://mdn.mozillademos.org/files/4127/border.png") ;
border-image-slice: 44;
border-image-width: 5% 15% 10%;
margin-top: 10px;
}
.bi4{
width: 100px;
height: 100px;
border: 40px solid transparent;
border-image: linear-gradient(red,black) 10;
margin-top: 10px;
}
</style>
</head>
<body>
<p>如果只设置border-image-source,图片会被缩放防在四个角,相当于border-image-slice的值为100%</p>
<div class="bi1"></div>
<p>border-image-slice:截取图片的一部分放在相应的位置上</p>
<div class="bi2"></div>
<p>border-image-width:背景图片大小</p>
<div class="bi3"></div>
<p></p>
<div class="bi4"></div>
</body>
</html>
0%