#border_image_top {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
}
#border_image {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
border-image: url(/static/assets/tutorials/front/css/border.png) 30 round;
text-align: center;
}
#border_image2 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 30 stretch;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 30 stretch;
border-image: url(/static/assets/tutorials/front/css/border.png) 30 stretch;
text-align: center;
}
#border_image3 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 50 round;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 50 round;
border-image: url(/static/assets/tutorials/front/css/border.png) 50 round;
text-align: center;
}
#border_image4 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 20% round;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 20% round;
border-image: url(/static/assets/tutorials/front/css/border.png) 20% round;
text-align: center;
}
#border_image5 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(/static/assets/tutorials/front/css/border.png) 30% round;
-o-border-image: url(/static/assets/tutorials/front/css/border.png) 30% round;
border-image: url(/static/assets/tutorials/front/css/border.png) 30% round;
text-align: center;
}
CSS3 图片边框
CSS3 图片边框
使用CSS3 border-image
属性, 你可以在元素的周围设置图片边框.
浏览器支持
表中的数字指定完全支持该属性的第一个浏览器版本。
数字后面的 -webkit- 或者 -moz- 使用时需要指定前缀。
属性 | |||||
---|---|---|---|---|---|
border-image | 16.0 4.0 -webkit- |
11.0 | 15.0 3.5 -moz- |
6.0 3.1 -webkit- |
15.0 11.0 -o- |
CSS3 border-image
属性
CSS3 border-image
属性允许您指定要用来代替元素周围的正常边界的图像。
属性有三个部分:
- 作为边框的图片
- 在哪里分割图像
- 确定中间部分应重复或延伸
我们将使用下面的图像(叫做 "border.png"):
border-image
性将图像分割成九个部分,就像一个井字游戏板。然后将角放在拐角处,中间部分按指定的顺序重复或拉伸。
注意: 让border-image
正常工作, 元素也需要设置边框属性!
在这里,图像的中间部分重复创建边界:
图片作为边框!
代码如下:
#borderimg {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 30 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 30 round; /* Opera 11-12.1 */
border-image: url(border.png) 30 round;
}
让我试试
在这里,图像的中间部分延伸到创建边界:
使用图片作为边框!
下面是实例代码:
#borderimg {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 30 stretch; /* Safari 3.1-5 */
-o-border-image: url(border.png) 30 stretch; /* Opera 11-12.1 */
border-image: url(border.png) 30 stretch;
}
让我试试
注意:
border-image
属性是border-image-source
,border-image-slice
,border-image-width
,border-image-outset
和border-image-repeat
的缩写.
CSS3 border-image
- 不同的切片值
不同的切片值完全改变边框的样子:
实例 1:
border-image: url(border.png) 50 round;
实例 2:
border-image: url(border.png) 20% round;
实例 3:
border-image: url(border.png) 30% round;
代码如下:
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 20% round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 20% round; /* Opera 11-12.1 */
border-image: url(border.png) 20% round;
}
#borderimg3 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 30% round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 30% round; /* Opera 11-12.1 */
border-image: url(border.png) 30% round;
}
让我试试
CSS3 边框属性
属性 | 描述 |
---|---|
border-image | 设置所有图片边框的快捷方式border-image-* |
border-image-source | 作为边框的图片路径 |
border-image-slice | 指定如何切片图片 |
border-image-width | 指定边框的宽度 |
border-image-outset | 指定边框图像区域超出边框的数量 |
border-image-repeat | 指定图片边框是否重复、环绕还是伸缩 |
本文转自:http://codingdict.com/article/2007
原文地址:https://www.cnblogs.com/bczd/p/12059154.html