2013-04-29 67 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

相關問題