【问题标题】:Rounded image corners in IE8IE8中的圆角图像
【发布时间】:2012-08-05 13:28:54
【问题描述】:

我有一些动态生成的图像:

<div class="image">
<?php echo "<img class='logo_client' src='img/clients/".$row['logo_name'].".jpg''>"; ?>
</div>

我希望它们有圆角,以便在我的 CSS 中放置:

.image {
padding: 0;
width: 100px;
height: 100px;
overflow: hidden;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-o-border-radius: 10px; 
border-radius: 10px;    
behavior: url(css/PIE.php);
}

我可以在 Firefox、Chrome 和 IE9 中看到圆角,但在 IE8 中不起作用。 PIE 的东西已经与 IE8 中的其他元素一起使用了。

有人知道它是什么吗?

非常感谢

【问题讨论】:

标签: css image internet-explorer-8 rounded-corners css3pie


【解决方案1】:

我知道让圆角在 IE8 及以下版本中工作的唯一方法是使用如下代码:

<div class="image">
   <span class="tl"></span>
   <span class="tr"></span>
   <span class="br"></span>
   <span class="bl"></span>
</div>

然后使用这样的 CSS:

.image { position: relative; }
.tl, .tr, .br, .bl { position: absolute; }
.tl { left: 0; top: 0; width: 20px; height: 20px; background: url(/images/tl.png) no-repeat top left; }
.tr { right: 0; top: 0; width: 20px; height: 20px; background: url(/images/tr.png) no-repeat top left; }
.br { right: 0; bottom: 0; width: 20px; height: 20px; background: url(/images/br.png) no-repeat top left; }
.bl { left: 0; bottom: 0; width: 20px; height: 20px; background: url(/images/bl.png) no-repeat top left; }

其中背景图像是与该角对应的所有圆角图像,例如右下角的背景图片可能如下所示:

还有一个(希望有道理)

可能有更好的方法可以做到这一点,因为上述方法有点费力,而且不是特别干净。

话虽如此,我怀疑任何让圆角在 IE8 及更低版本中工作的方法都会特别“干净”。 IE8及以下的浏览器我一般都是不加圆角的,和其他浏览器相比,现在连7和8都用不了了。

编辑:

如果我是你,我会避开类似“behavior: url(css/PIE.php);”这样的代码其他浏览器不支持 IE 行为,我想连微软都放弃了。

【讨论】:

    【解决方案2】:

    最后我让它与 CSS3 PIE 一起工作。圆角出现在 IE7、IE8 和所有其他浏览器中。这是一个编码错误,抱歉。

    【讨论】:

    • 您介意解释一下错误是什么,然后接受这个答案吗?
    猜你喜欢
    • 2011-10-27
    • 2012-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    相关资源
    最近更新 更多