0

我正在做一个简单的网站。在这个网站中,我在不同的层中有几个 div(一个在另一个前面,依此类推)。后面的两个 div 没有问题,但是当我调整浏览器的大小时,前面的 div 会移动,我不希望这样。奇怪的是,后面的 div 是以相同的方式创建的。所以基本上让我的页面混乱的是:#icone_esquerda#icone_direita。下面是我的代码:

<style type="text/css">

#fundo{
    background-image:url("tileable_wood_texture_copy.png"); 
    background-repeat:repeat;
    position:fixed;
    width:100%;  
    height:100%;    
    top:0;
    left:0;
}

#frente{
    background-image:url("luinguica.png"); 
    background-repeat:no-repeat;
    background-position:top center;
    position:fixed;
    width:inherit;  
    height:inherit; 
    left: 0;
    top: 0;
    z-index:50;
}

#icone_esquerda{
    background-image: url("botao_facebook.png");
    background-position: bottom center;
    background-repeat: no-repeat;
    height: 50px;
    left: 45%;
    margin: -25px 0 0 -25px;
    position: fixed;
    top: 45%;
    width: 50px;
    z-index: 60;       
}

#icone_direita{
    background-image: url("botao_mail.png");
    background-position: bottom center;
    background-repeat: no-repeat;
    position: fixed;
    width: 50px;
    height: 50px;
    left: 53%;
    top: 45%;
    margin: -25px 0 0 -25px;
    z-index: 60;

}

</style>
</head>

<body>
  <div id="fundo">
     <div id="frente">    
         <a href="http://www.facebook.com/confrariadaempada">
            <div id="icone_esquerda">
            </div>
         </a>
         <a href="mailto:info@confrariadaempada.pt">
            <div id="icone_direita">
            </div>
         </a>
     </div>
   </div>
</body>

当我调整浏览器的大小时,id 为 icone_esquerda 和 icone_direita 的 div 会移动!任何人都可以帮助我吗?

提前致谢。

4

1 回答 1

0

Fixed应该将它保存在基于屏幕的指定区域 - 它在哪里,它的大小等。

Absolute让它保持原样,无论在哪里或多大。

真的,它们都应该很少(如果有的话)被使用。最好根据需要学习使用Relative带有浮动的定位元素(当然,正确清除)。

于 2013-04-30T00:01:38.687 回答