简体   繁体   English

带有CSS的IE7中的背景渐变

[英]background gradients in IE7 with CSS

I am using the following bit of CSS to create a linear background gradient. 我正在使用以下CSS来创建线性背景渐变。 It seems to work just fine in IE8/9, FF, Safari and chrome but not in IE7. 在IE8 / 9,FF,Safari和chrome中似乎可以正常工作,但在IE7中却不能。 IE7 shows a solid (green) background. IE7显示稳定的(绿色)背景。 Here is my code 这是我的代码

.menu_body a {
  display:block;
  color:#006699;
  background: #008800;
  /* Mozilla: */
  background: -moz-linear-gradient(top, #0b71a4, #025f8e);
  /* Chrome, Safari:*/
  background: -webkit-gradient(linear,
            left top, left bottom, from(#0b71a4), to(#025f8e));
  /* MSIE */
  filter: progid:DXImageTransform.Microsoft.Gradient(
            StartColorStr='#0b71a4', EndColorStr='#025f8e', GradientType=0);
  padding: 1px 18px;
}   

In IE<=7, filters won't work unless element has layout . 在IE <= 7中,除非element具有layout,否则过滤器将不起作用。

zoom: 1;

Be aware that it can break other things, so old good background-image might be safe and reliable solution. 请注意,它可能会破坏其他东西,因此旧的良好background-image可能是安全可靠的解决方案。

Also please note that your CSS lacks gradient properties for Opera, IE10 and updated syntax for Webkit. 还请注意,您的CSS缺少Opera,IE10的渐变属性和Webkit的更新语法。

The correct syntax is: 正确的语法是:

filter: progid:DXImageTransform.Microsoft.gradient
(startColorstr=#550000FF, endColorstr=#55FFFF00)

This is supported by IE4> IE4支持此功能>

See the MSDN source here . 此处查看MSDN源代码。

I'm unsure if the parameters of this transform are case sensitive - but seeing as most other CSS is, you could try: 我不确定此转换的参数是否区分大小写-但与其他大多数CSS一样,您可以尝试:

startColorstr='#0b71a4', endColorstr='#025f8e'

Notice the lower-case starting character, and lower-case str suffix. 请注意小写的起始字符和小写的str后缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM