2013-04-24 55 views
-1

如何使z指數適合頁面,而不是縮小我需要從svg,但我的svg適合頁面。如何使z指數適合頁面,而不是縮小

這裏是我的div代碼

<div id="homeScreen" class="grey_box" style="background-color:#CDCDCD; 
    position: absolute; 
    left: 0px; 
    top: 8px; 
    width: 373px; 
    height: 537px; 
    visibility: visible;"> 
<p class="hello" >E-Number<input id="tags" /></p> 
<p class="hello2">Mat-Number<input id="tags1" /><p> 
<p class="hello3">Tech. ID<input type="text" name="fname"><p> 
<p class="hello4">RIS<input type="text" name="fname"><p> 
<p class="hello5"> <button onclick="get_action_home()" style="width: 100px">Continue</button><p> 
<p class="hello6">Βάση δεδομένων: Τοπικός</p> 
<p class="hello7">Σύνδεση: κομμένη</p> 
<p class="hello8">Κατάσταση βάσης δεδ.: Μη επίκαιρη</p> 

</div> 

這裏是把它dinamically

function adjust() 
{ 

      var DMMScreen = document.getElementById("DMM"); 
      //new screens dinamic 
      var homeScreen = document.getElementById("homeScreen"); 



      homeScreen.style.height = DMMScreen.getBoundingClientRect().height; 
      homeScreen.style.width = DMMScreen.getBoundingClientRect().width; 
      homeScreen.style.top = DMMScreen.getBoundingClientRect().top; 
      homeScreen.style.left = DMMScreen.getBoundingClientRect().left; 
      // 

這裏的JavaScript是我從jQuery的發現,但我不知道如何解決它

$(window).resize(function() { 
    $("#width").text($(this).width()); 
    $("#height").text($(this).height()); 
}); 

這裏是鏈接,它做什麼 [鏈接](https://www.dropbox.com/s/ebsha1t091ewk40/good2.png)和 這裏是不好的時候我的窗口 [鏈接](https://www.dropbox.com/s/b7n4nn3gg2gb6fn/good.png

回答

1

z-index犯規適合改變任何東西,這是一個「分層」工具,讓您放置元素在彼此的頂部,我假設你的意思是你有一個position:fixedposition:absolutez-index結合..如果是這樣的話可以使元素適合頁面寬度使用width:100%;

例如:

<style> 
.full_width { 
    top:0; 
    left:0; 
    z-index:1; 
    height:20%; 
    width:100%; 
    position:fixed; 
    text-align:center; 
} 
</style> 
</head> 
<body> 
    <div class="full_width"> i will fit the width of the page</div> 

    your other stuff here... 
</body> 

如果這不是你的意思,那麼請提供更多信息..

編輯 您所提供的鏈接,你並不需要使用positionz-index

這是怎麼回事像設置您margin-leftmargin-rightauto並限定容器width簡單..

的HTML CSS &該網頁粘貼到你的問題,我們可以給你更多的幫助

,但因爲它的立場,讓這個盒子在頁面中間的一個例子是

<style> 
.grey_box { 
    width:500px; 
    height:600px; 
    margin-left:auto; 
    margin-right:auto; 
    background-color:#CCC; 
} 
</style> 
<div class="grey_box"> 
<!-- your content here--> 
</div> 

例如:http://jsfiddle.net/AbQsa/

+0

好一個[鏈接](HTTPS://www.dropbox。 com/s/ebsha1t091ewk40/good2.png),這裏是錯誤的[鏈接](https://www.dropbox.com/s/b7n4nn3gg2gb6fn/good.png?m),這是不適合頁面! – Cbour 2013-04-24 10:27:09

+0

我已經更新了我的答案..我希望這可以幫助 – 2013-04-24 10:40:44

相關問題