## border-image 属性
## 定义和用法
border-image 属性是一个简写属性,用于设置以下属性:
* border-image-source
* border-image-slice
* border-image-width
* border-image-outset
* border-image-repeat
如果省略值,会设置其默认值。
提示:请使用 border-image-\* 属性来构造漂亮的可伸缩按钮!
JavaScript 语法:object.style.borderImage="url(border.png) 30 30 round"
## 可能的值
| 值 | 描述 | 测试 |
| --- | --- | --- |
| *border-image-source* | 用在边框的图片的路径。 | |
| *border-image-slice* | 图片边框向内偏移。 | |
| *border-image-width* | 图片边框的宽度。 | |
| *border-image-outset* | 边框图像区域超出边框的量。 | |
| *border-image-repeat* | 图像边框是否应平铺(repeated)、铺满(rounded)或拉伸(stretched)。 | [测试](https://www.w3cschool.cn/statics/demosource/css-border-image.html) |
## 实例--[Border-image 按钮](https://www.w3cschool.cn/tryrun/showhtml/trycss_border-image_button)
```
<!DOCTYPE html>
<html>
<head>
<title>W3Cschool(w3cschool.cn)</title>
<style>
div
{
border:10px solid transparent;
width:40px;
padding:5px 10px;
-moz-border-image: url(/statics/demosource/border_image_button.png) 0 14 0 14 stretch; /* 老版本的 Firefox */
-webkit-border-image: url(/statics/demosource/border_image_button.png) 0 14 0 14 stretch; /* Safari */
-o-border-image: url(/statics/demosource/border_image_button.png) 0 14 0 14 stretch; /* Opera */
border-image: url(/statics/demosource/border_image_button.png) 0 14 0 14 stretch;
}
</style>
</head>
<body>
<p><b>注释:</b>Internet Explorer 不支持 border-image 属性。</p>
<div>Search</div>
<p>这是我们使用的图片:</p>
<img src="/statics/demosource/border_image_button.png">
</body>
</html>
```
将图片规定为包围 div 元素的边框:
~~~
div
{
-webkit-border-image:url(border.png) 30 30 round; /* Safari 5 */
-o-border-image:url(border.png) 30 30 round; /* Opera */
border-image:url(border.png) 30 30 round;
}
~~~
- CSS常用样式控制
- background--背景
- Text--文本
- CSS属性
- align-*
- animation-*
- appearance
- backface-visibility
- background
- background-attachment
- background-blend-mode
- background-clip
- background-color
- background-image
- background-origin
- background-position
- background-repeat
- background-size
- border
- border-bottom
- border-bottom-color
- border-bottom-left-radius
- border-bottom-right-radius
- border-bottom-style
- border-bottom-width
- border-collapse
- border-color
- border-image
- border-image-outset
- border-image-repeat
- border-image-source
- border-image-width
- Border-left
- border-left-color
- border-left-style
- border-left-width
- border-image-slice
- border-radius
- border-right
- border-right-color
- border-right-style
- border-right-width
- border-spacing
- border-style
- border-top
- border-top-color
- border-top-left-radius
- border-top-right-radius
- border-top-style
- border-top-width
- border-width
- bottom
- box-shadow
- box-sizing
- caption-side
- clear
- clip
- color
- column-count
- column-gap
- column-rule
- column-rule-color
- column-rule-style
- column-rule-width
- column-span
- column-width
- columns
- content
- counter-increment
- counter-reset
- cursor
- direction
- display
- Empty-cells
- filter(滤镜)
- CSS 伪元素选择器
- :active 选择器
- :after 选择器
- :before 选择器
- :checked 选择器
- :disabled 选择器
- :empty 选择器
- :enabled 选择器
- :first-child 伪元素
- :first-letter 伪元素
- :first-line 伪元素
- :first-of-type 选择器
- :focus 选择器
- :hover 选择器