我有一個問題等同於這張海報: Jquery problem with height() and resize()JQuery的:動力高度()的窗口大小調整()
但解決不解決我的問題。我有三個堆疊的div,我想使用JQuery使中間的高度調整到窗口高度的100%,減去其他頂部底部div的高度(23px * 2)。它適用於調整大小,但當文檔初始加載時它關閉(短)16px。
HTML
<body>
<div id="bg1" class="bg">top</div>
<div id="content">
help me. seriously.
</div>
<div id="bg2" class="bg">bottom</div>
</body>
CSS
html,
body {
width:100%;
height:100%;
}
.bg {
width:315px;
height:23px;
margin:0 auto;
text-indent:-9000px;
}
#bg1 {background:url(../images/bg1.png) 0 50% no-repeat;}
#bg2 {background:url(../images/bg2.png) 0 50% no-repeat;}
#content {
width:450px;
margin:0 auto;
text-align: center;
}
JQuery的
$(document).ready(function(){
resizeContent();
$(window).resize(function() {
resizeContent();
});
});
function resizeContent() {
$height = $(window).height() - 46;
$('body div#content').height($height);
}
我在找這樣的東西嗎?或者頁腳是否應該隨頁面一起移動? http://www.cssplay.co.uk/layouts/basics2.html小提琴會很好! – mrtsherman
我可以做那樣的事情,但我堅持使用服務器端生成的HTML。我被要求用JQuery來解決這類問題。 – Gregir
什麼是9000px文字縮進? – mrtsherman