[英]Full height class doesn't make div the full height
這是我的代碼: http : //jsfiddle.net/spadez/LQKfk/2/
HTML:
<div id="main">
<div id="header" class="fullheight">
<div id="nav">Test</div>
Nav
</div>
<div id="content">
Hello
</div>
</div>
CSS:
*{padding: 0px; margin: 0px;}
#main{
background-color: #3B2F63;
background-image: -webkit-radial-gradient(50% top, rgba(84,90,182,0.6) 0%, rgba(84,90,182,0) 75%),-webkit-radial-gradient(right top, #794aa2 0%, rgba(121,74,162,0) 57%);
background-repeat: no-repeat;
background-size: 100% 1000px;
color: #c7c0de;
margin: 0;
padding: 0;
}
#header { }
#content{background-color: white;}
.fullheight{
display: block;
position: relative;
height: 100%;
}
使用此代碼,為什么漸變區域不能擴展窗口的整個高度?
全高基本上與文檔有關。 您需要使文檔至少達到窗口的最高高度,以使文檔中的div達到窗口的全部高度。
但是,如果您的文檔中包含的內容可能比當前窗口的大小更多,那么實現此操作可能會很棘手。
擺弄SW4的小提琴並進行更改
height: 100%;
在html, body
min-height: 100%;
看到這個派生的小提琴: http : //jsfiddle.net/SGjcc/1/
html,body, #id_of_div_you_want_to_make_full_heightwidth_of_window{
height:100%;
width:100%;
}
html,body, #main
{
height:100%;
}
您可以嘗試以下代碼:
#main{
background-color: #3B2F63;
background-image: -webkit-radial-gradient(50% top, rgba(84,90,182,0.6) 0%, rgba(84,90,182,0) 75%),-webkit-radial-gradient(right top, #794aa2 0%, rgba(121,74,162,0) 57%);
background-repeat: no-repeat;
background-size: 100% 1000px;
color: #c7c0de;
margin: 0;
padding: 0;
height:100%;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.