【发布时间】:2012-09-25 11:35:24
【问题描述】:
我目前正在使用 CSS3 border-image 并注意到在 Chrome 和 FireFox(最新版本)之间应用图像的方式存在差异。
我有一个非常基本的示例,我正在处理其中我将border-image 应用于一些textarea 标记来研究不同的效果。
在 FireFox 中,图像被分割成多个部分,并按预期应用到边框部分。正如我所期望的那样,中心是透明的。
在 Chrome 中,它对边框的作用相同,但也显示图像的中心。
浏览器是否应用了一些默认设置/样式,导致一个浏览器透明但另一个浏览器不透明?
这是我可以覆盖的设置/样式吗?
The Fiddle
编辑
我想,看到浏览器只是这样做,如果不能 过度编写 CSS 中的行为,我能做些什么来确保图像 在 2 个浏览器之间应用相同吗?
万一小提琴过时了,我也包括了下面的代码。
HTML:
<textarea class="no-image">some default text</textarea>
<textarea class="stretch">some default text</textarea>
<textarea class="round">some default text</textarea>
<textarea class="repeat">some default text</textarea>
CSS:
textarea{
border: 50px solid #feb515;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
width: 500px;
height: 100px;
padding: 15px;
border-image-slice: 5;
}
textarea.stretch{
border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 stretch;
-moz-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 stretch;
-webkit-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 stretch;
}
textarea.round{
border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 round stretch;
-moz-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 round stretch;
-webkit-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 round stretch;
}
textarea.repeat{
border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 repeat round;
-moz-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 repeat round;
-webkit-border-image: url(http://www.w3.org/TR/css3-background/groovy-border-image-slice.png) 100 repeat round;
}
【问题讨论】:
-
太奇怪了——所以这个css技巧的例子对我来说似乎工作正常,但你的js小提琴不是。我不知道为什么。 css-tricks.com/understanding-border-image
-
@quoo:这很奇怪。我仔细检查了w3.org/TR/css3-background/#border-image-slice 的文档,它确实在
border-image-sliceThe ‘fill’ keyword, if present, causes the middle part of the border-image to be preserved. (By default it is discarded, i.e., treated as empty.)下说,我想知道 Chrome 是否有默认设置。
标签: css