diff options
Diffstat (limited to 'files/zh-cn/web/css/border-image/index.html')
| -rw-r--r-- | files/zh-cn/web/css/border-image/index.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/border-image/index.html b/files/zh-cn/web/css/border-image/index.html new file mode 100644 index 0000000000..079924c67d --- /dev/null +++ b/files/zh-cn/web/css/border-image/index.html @@ -0,0 +1,92 @@ +--- +title: border-image +slug: Web/CSS/border-image +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - border-image +translation_of: Web/CSS/border-image +--- +<div>{{CSSRef}}</div> + +<p><code><strong>border-image </strong></code>CSS属性允许在元素的边框上绘制图像<code>。这使得绘制复杂的外观组件更加简单,也不用在某些情况下使用九宫格了。使用 border-image 时,其将会替换掉 </code>{{cssxref("border-style")}} 属性所设置的边框样式。虽然规范要求使用 <code>border-image 时</code>边框样式必须存在,但一些浏览器可能没有实现这一点。</p> + +<p>特别注意,若 {{cssxref("border-image-source")}}(此值可用<span style="font-family: consolas,monaco,andale mono,monospace;">border-image-source或border-image简写设置)</span> 的值为 none 或者图片不能显示,则将应用 border-style。</p> + +<p>{{cssinfo}}</p> + +<h2 id="语法">语法</h2> + +<pre class="syntax">/* border-image: image-source image-height image-width image-repeat */ +border-image: url("/images/border.png") 30 30 repeat; +border-image: url("/images/border.png") 30 30 stretch; +</pre> + +<h3 id="值">值</h3> + +<p>参考各属性对应的值。</p> + +<h3 id="正式语法">正式语法</h3> + +<pre class="syntaxbox" style="font-size: 14px; white-space: normal;">{{csssyntax}}</pre> + +<h2 id="示例">示例</h2> + +<h3 id="位图" name="位图">位图</h3> + +<h4 id="HTML_内容">HTML 内容</h4> + +<pre class="brush: html"><div id="bitmap">The image is stretched to fill the area.</div></pre> + +<h4 id="CSS_内容">CSS 内容</h4> + +<pre class="brush: css">#bitmap { + border: 30px solid transparent; + padding: 20px; + border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 30; +} +</pre> + +<p>{{ EmbedLiveSample('位图') }}</p> + +<h3 id="渐变" name="渐变">渐变</h3> + +<h4 id="HTML_内容_2">HTML 内容</h4> + +<pre class="brush: html"><div id="gradient">The image is stretched to fill the area.</div></pre> + +<h4 id="CSS_内容_2">CSS 内容</h4> + +<pre class="brush: css">#gradient { + border: 30px solid; + border-image: linear-gradient(red, yellow) 10; + padding: 20px; +} +</pre> + +<p>{{ EmbedLiveSample('渐变') }}</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('CSS3 Backgrounds', '#border-image', 'border-image')}}</td> + <td>{{Spec2('CSS3 Backgrounds')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div>{{Compat("css.properties.border-image")}}</div> |
