## 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 選擇器