2016-11-23 44 views
0

您好我有跟隨着DIV:CSS + jQuery的如何讓一個div浮在其他分區的內容

<div class="pleaseWait"> 
      <img src="animation.svg" /> 
     </div> 

enter image description here

我有它僅低於我<body>標籤。

我的風格:

.pleaseWait{ 
    margin: 0px auto; 
    text-align: center; 
    margin-top: 200px; 
    display: none; 
} 

現在,使用jQuery取決於Ajax調用或任何我想在中心頁面上方顯示<div>

$('.pleaseWait').show(); 

任何線索我必須添加什麼css風格才能得到這個結果。我希望這能夠做出反應,所以如果我把瀏覽器縮小一點,它就會隨之移動。

順便說一句,我參考modernizr.min.js萬一有效。

+0

可你至少出現畫面? –

+0

爲了使用'margin:0 auto;',你需要給'',pleaseWait'一個寬度。 – BenM

+0

'position:fixed;頂部:50%;剩下:50%; margin-top:(svg height/-2)px; margin-left:(svg width/-2)px; z-index:9999;' – Phil

回答

0

你爲什麼不使用的z-index設置圖像在你的頁面的其他元素的前面,就像這樣:

.pleaseWait { 
margin: 0px auto; 
text-align: center; 
margin-top: 200px; 
display: none; 
z-index:2; 
} 
+0

'2'看起來相當低,因此得到的東西最多 – Phil

+1

此外,「z-index隻影響具有非靜態位置值的元素(默認值)」 - https:// css -tricks.com/almanac/properties/z/z-index/ – DaMaGeX

+0

是的,必須與位置:絕對。 –