2013-04-29 66 views
0

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

<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:[email protected]"> 
      <div id="icone_direita"> 
      </div> 
     </a> 
    </div> 
    </div> 
</body> 

当我调整浏览器的div与IDS icone_esquerda和icone_direita移动! 任何人都可以帮助我吗?

在此先感谢。

+1

移动到什么意义上?尝试在[小提琴](http://www.jsfiddle.net)中复制您的问题。 – Terry 2013-04-30 00:01:40

+0

从我在这里看到的,如果你使用%值,它是正常的,因为他们的父母div的大小与窗口宽度 – 2013-04-30 00:10:35

回答

0

Fixed应该保持它在基于屏幕上的指定区域 - 它在哪里,它是什么尺寸等

Absolute使得它留在原地,无论在什么地方或什么大小。

真的,他们两人应该很少(如果有的话)被使用。学习如何根据需要使用Relative定位元素和浮点数(当然,要正确清除)更好。

+0

我已绝对尝试过,但当浏览器调整大小时出现同样的问题。我试图把它作为相对的,但没有任何运气。 – MOliveira30 2013-04-30 16:13:35

+0

什么是我的页面真正的问题?? PLease的帮助! – MOliveira30 2013-04-30 17:27:01

相关问题