CSS3Pie margins sets to zero

2019-09-15 08:51发布

I have such css

.corner-wrapper
{
    display:table;
    position:relative;
    border: 2px solid #69b0ff;  
    margin:5px 0 5px 0;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    behavior: url("PIE.htc");   
}

The rounded corners seams to be added in all IE old versions, it is really cool, but i noticed that margings getting lost. I googled and found some links related to that, looks like there is some bugs behind that. http://css3pie.com/forum/viewtopic.php?f=3&t=92 and http://css3pie.com/forum/viewtopic.php?f=3&t=364

So and my question is - What is the better and more efficient workaround for that?

1条回答
够拽才男人
2楼-- · 2019-09-15 09:22

Here's something that worked for me (I posted it on the pie forum as well) - Put this right after the body tag (does not work if in the header):

<!--[if lte IE 7]>
<script type='text/javascript'>
document.body.onload = function(){
 document.body.style.zoom = '2';
 document.body.style.zoom = '1';
}
</script>
<![endif]-->

Then, in your css, to each "pie"d element that has a bottom margin, add an "expression" statement for the bottom margins like this:

.my_div {margin-bottom: 10px; margin-bottom: expression('10px');}

Borderless elements still not showing correct margins may require a border (something like "border-bottom: 1px solid transparent;" is fine. do not follow it with a "margin-bottom: -1px" to cancel it or it won't work). Also, you will still need to wrap floating elements in the pie'd element in their own wrapper (plain div will do) if you want absolute elements in the pie'd element to appear. (no idea what the connection is, but it works)

查看更多
登录 后发表回答