2

我有以下代码:

 <style>
            .earthlogo{float: right; margin: -270px 0px 0px 0px;}
 </style>

    <div class="banner">   
        <p>ENVISIONING A BETTER TOMORROW</p> 
        <div class="earthlogo">
            <img src="images/earth.png"/>
        </div>
    </div>

在这里,我将负边距应用于类earthlogo及其在 firefox 和 google chrome 中的工作,但在 IE 7 中没有。所以这是在 CSS 中应用负边距的正确方法,如果它是正确的方法,那么为什么它在 IE 7 中不起作用。如何我可以修复 IE 问题吗?

谢谢

4

2 回答 2

2

margins您可以使用position: relative;负数topleft偏移量来代替负数;

.earthlogo {
     position: relative;
     top: -270px; /*pull it 270 pixels up*/
     left: 0px; /*we don't want to pull it to the left*/
     margin: 0px; /*make sure no margins are applied*/
}
于 2012-09-28T10:27:56.020 回答
1

您可以使用

position: relative;

随着

 top:270px left:0px offsets
于 2013-07-09T11:57:52.537 回答