简体   繁体   English

IE9中的渐变+圆角CSS问题

[英]Gradient + Rounded Corner CSS Issue in IE9

In my current project, I've used CSS3 gradient in my CSS file. 在当前项目中,我在CSS文件中使用了CSS3渐变。 To support IE browser, I've used filter property as well. 为了支持IE浏览器,我也使用了filter属性。 Following is my code: 以下是我的代码:

.card.active .content.back {
  background: #333; /* Old browsers */
  background: -moz-linear-gradient(top, #333 0%, #0e0e0e 100%); /* FF3.6+ */
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#333), color-stop(100%,#0e0e0e)); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(top, #333 0%,#0e0e0e 100%); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(top, #333 0%,#0e0e0e 100%); /* Opera11.10+ */
  background: -ms-linear-gradient(top, #333 0%,#0e0e0e 100%); /* IE10+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#333333', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
  background: linear-gradient(top, #333 0%,#0e0e0e 100%); /* W3C */

}

But when I use the filter property in the above code, the border-radius property is not working. 但是当我在上面的代码中使用filter属性时, border-radius属性不起作用。 If anyone know a fix for this, please share it with me. 如果有人知道解决方法,请与我分享。

Thanks 谢谢

You can use PIE.htc for your desired results. 您可以使用PIE.htc获得所需的结果。

PIE stands for Progressive Internet Explorer. PIE代表渐进Internet Explorer。 It is an IE attached behavior which, when applied to an element, allows IE to recognize and display a number of CSS3 properties. 这是IE附带的行为,当应用于元素时,它允许IE识别并显示许多CSS3属性。

PIE currently adds full or partial support to IE 6 through 8 for the following CSS3 features: PIE当前为以下CSS3功能向IE 6至8添加了全部或部分支持:

border-radius
box-shadow
border-image
multiple background images
linear-gradient as background image

In addition, PIE adds support for border-image and linear-gradient to IE 9, which already supports the other features natively. 此外,PIE在IE 9中增加了对边框图像和线性渐变的支持,而IE 9已经本地支持其他功能。

http://css3pie.com/ http://css3pie.com/

or see the demo:- http://jsfiddle.net/ZxzSs/1/ 或查看演示: -http : //jsfiddle.net/ZxzSs/1/

for support PIE.htc you have to keep the PIE.htc file on your root folder than will work for your website.... 为了支持PIE.htc,您必须将PIE.htc文件保留在根目录下,而不适合在您的网站上使用。...

You should be able to apply the gradient to a child of the element with the rounded corners. 您应该能够将渐变应用于具有圆角的元素的子级。 I don't have access to IE9 on my home machine but this should work: 我没有在家用计算机上访问IE9的权限,但这应该可以工作:

.element {
    background: linear-gradient(top, #333 0%,#0e0e0e 100%); /* W3C */
    border-radius: 10px;
}
.element .ie-helper {
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#0e0e0e',GradientType=0 );
}

HTML: HTML:

<div class="element">
    <!--[if lt IE 9]><div class="ie-helper"><![endif]-->
    <p>Your content with gradient and rounded corners...</p>
    <!--[if lt IE 9]></div><![endif]-->
</div>

If the page is viewed in IE10+ or other browsers, both the gradient and rounded corners will apply to same element (assuming you bring back the vendor-specific prefixes from your code sample). 如果在IE10 +或其他浏览器中查看了该页面,则渐变和圆角都将应用于同一元素(假设您从代码示例中带回了供应商特定的前缀)。 The inner div.ie-helper will only render on IE9 and below because of the conditional comments used. 内部的div.ie-helper将仅在IE9及更低版本上呈现,这是因为使用了条件注释

This isn't ideal but would get the job done, but since you're after such a wide range of browsers to be fully supported this is a reasonable workaround 这不是一个理想的方法,但是可以完成工作,但是由于您需要广泛支持的各种浏览器,因此这是一个合理的解决方法

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

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