且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS3边框半径和Internet Explorer 8

更新时间:2023-11-15 13:10:04

我不知道你正在使用border-radius.htc文件,但如果你使用 CSS3 PIE ,它是已知问题。从他们的页面:


我知道解决这个问题的唯一方法是:




  • 使目标元素位置:relative,或

  • 使祖先元素位置:relative,并为其赋予z-index。



这两种解决方法在子元素定位和z-index堆叠方面都有潜在的不良副作用。 PIE很容易强迫一个或另一个本身,但:




  • 根据具体情况,一个或另一个可能更合适, CSS作者需要能够控制选择哪一个。

  • 强制位置:CSS之外的相对位置会使IE与其他浏览器不同步,导致混乱的不一致。



I am using CSS3 border-radius styles in my webpage and I want it to be cross-browser compliant across major browsers including IE8.

Therefore, I am trying to use the border-radius.htc file to achieve this. Wherever in my css styles the border-radius is used, i have coded something like:

   -webkit-border-radius: 6px 6px 6px 6px;
    border-radius: 6px 6px 6px 6px; 
    behavior:url(border-radius.htc);

Unfortunately, when I check the webpage in IE8, all the backgrounds that have border-radius behavior end up not showing at all.

The webpage is at http://www.domainandseo.com/portfolio/dominos/index.html

Any suggestions would be highly appreciated.

I don't known which "border-radius.htc" file you're using, but if you're using something like CSS3 PIE, it's a known issue. From their page:

The only way I know of to work around this is to either:

  • make the target element position:relative, or
  • make the ancestor element position:relative and give it a z-index.

Both of these workarounds can have potential unwanted side-effects in terms of child element positioning and z-index stacking. PIE could easily force one or the other itself, but:

  • One or the other may be more appropriate depending on the particular situation, so the CSS author needs to be able to control which one gets chosen.
  • Forcing position:relative outside of the CSS would put IE out of sync with other browsers, leading to confusing inconsistencies.