【发布时间】:2012-10-09 10:30:43
【问题描述】:
我正在生成一个水平渐变条作为我网站的背景,它在除...IE9 之外的所有浏览器中都能完美运行。
渐变本身是有效的,只是我想限制蓝条的高度。在 Safari/Firefox/Chrome 中查看,然后在 IE9 中查看,您可以看到蓝色渐变填充了整个元素。
Horizontal gradient bar using CSS
这是我的 CSS:
#inner {
background: #1e5799;
background: -moz-linear-gradient(top, #1e5799 0%, #0057be 35%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(35%,#0057be));
background: -webkit-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: -o-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: -ms-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: linear-gradient(to bottom, #1e5799 0%,#0057be 35%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#0057be',GradientType=0 );
background-size: 1px 10%;
background-repeat: repeat-x;
margin: 0 auto;
padding: 1em 0;
}
【问题讨论】:
-
我猜这是因为您的渐变是 css 制作的,因此要在 IE9 中使用 background-size 属性,您必须具有图像背景/彩色背景。所以
filter与 IE 中的background不同
标签: css background filter internet-explorer-9 gradient