[英]CSS gradients cross-browser
I have this CSS generated from this URL: http://ie.microsoft.com/testdrive/graphics/cssgradientbackgroundmaker/default.html 我有从以下URL生成的CSS: http : //ie.microsoft.com/testdrive/graphics/cssgradientbackgroundmaker/default.html
/* IE10 Consumer Preview */
background-image: -ms-radial-gradient(center bottom, circle closest-corner, #FFFFFF 0%, #BCD2E3 100%);
/* Mozilla Firefox */
background-image: -moz-radial-gradient(center bottom, circle closest-corner, #FFFFFF 0%, #BCD2E3 100%);
/* Opera */
background-image: -o-radial-gradient(center bottom, circle closest-corner, #FFFFFF 0%, #BCD2E3 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(radial, center bottom, 0, center bottom, 487, color-stop(0, #FFFFFF), color-stop(1, #BCD2E3));
/* Webkit (Chrome 11+) */
background-image: -webkit-radial-gradient(center bottom, circle closest-corner, #FFFFFF 0%, #BCD2E3 100%);
/* W3C Markup, IE10 Release Preview */
background-image: radial-gradient(circle closest-corner at center bottom, #FFFFFF 0%, #BCD2E3 100%);
How can I make this where it degrades well to older browsers and uses the image instead of the gradients? 如何在较旧的浏览器很好地降级并使用图像而不是渐变的情况下进行此处理?
Here is my current CSS with a background image, also, my image is currently 1600X144 and I'd like the center of the gradient centered accordingly.: 这是我当前带有背景图像的CSS,同时,我的图像当前为1600X144,我希望渐变的中心相应地居中。
.navbar .navbar-inner {
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 10px rgba(239, 24, 3, 0.1);
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 10px rgba(239, 24, 3, 0.1);
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 10px rgba(239, 24, 3, 0.1);
background: url(../images/bgHeader2.png);
}
The generated code already degrades for older browsers: they'll use the background-image: url(bgHeader2.png);
对于较旧的浏览器,生成的代码已经降级了:它们将使用
background-image: url(bgHeader2.png);
property value and disregard the gradient properties because they can't parse them (this is why the ordering of the properties is important). 属性值并忽略渐变属性,因为它们无法解析它们(这就是属性顺序很重要的原因)。
I can't see anything wrong besides the fact the generated code is very verbose. 除了生成的代码非常冗长之外,我看不到任何错误。
Others have mentioned that your example should work and degrade gracefully, so I won't go in to that. 其他人已经提到您的示例应该可以正常工作并降级,因此我将不再赘述。
As for your side note about centering the gradient-image. 至于您要注意的有关渐变图像居中的注意事项。 The easiest way to control the position of a background image is throught the
background-position
property. 控制背景图像位置的最简单方法是通过
background-position
属性。
Not sure how you wan't to position your background, but a wild guess is this: 不确定如何定位背景,但是很疯狂的猜测是:
background-position: center center;
You could also do it straight in the background-property: 您也可以直接在背景属性中执行此操作:
background: url(../images/bgHeader2.png) center center;
您确定只使用background: ....
而不是background-image:
会不会更好(我不知道这是否有帮助,但是如果您选中ColorZilla ,它将显示一个支持旧浏览器的示例。但是渐变应该可以在IE6中使用...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.