简体   繁体   English

IE 5-7(CSS)的渐变

[英]Gradients for IE 5-7 (CSS)

Okay so I am currently having problems with gradients in IE 5-7 (It needs to be in there for comptability reasons.) 好的,所以我目前在IE 5-7中遇到了渐变问题(出于兼容性考虑,它必须放在其中)。

I have tried using the following code: 我尝试使用以下代码:

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#edfdff', endColorstr='#b3e9ef',GradientType=1 ); /* IE6-8 */

However it does not display the gradient at all and simply displays a white background, the other code I am using for IE9+ and IE10+ works fine and has no issues, the same applies for all other browsers and the code used for them. 但是,它根本不显示渐变,而仅显示白色背景,我用于IE9 +和IE10 +的其他代码可以正常工作,没有任何问题,同样适用于所有其他浏览器以及用于它们的代码。

我通过简单地创建一个1像素的渐变,然后重复它并设置颜色来解决此问题。

background: #edfdff url(images/gradient_slice.png) 0 0 x-repeat; /* Old browsers */

According to MSDN , the element that you apply a gradient to must have layout. 根据MSDN ,应用渐变的元素必须具有布局。 That is, it must have either a width , a height or a position , otherwise the gradient won't be visible. 也就是说,它必须具有widthheightposition ,否则渐变将不可见。

So this jsFiddle works in IE6, but this one does not. 因此, 此jsFiddle可在IE6中使用,但此方法无效。

By the way, your own answer does not work like the example in your question. 顺便说一句,您自己的答案不能像问题中的示例那样工作。 First of all, x-repeat should be repeat-x . 首先, x-repeat应该是repeat-x And secondly, GradientType=1 repeats vertically, not horizontally. 其次, GradientType=1垂直而不是水平重复。

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

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