簡體   English   中英

div超出了背景色

[英]Div going beyond the background color

我想做的是,無論閱讀器的屏幕分辨率有多大,背景色都將保持不變。 我創建了一個div,其高度設置為auto。

.news-box{
margin-top:5%;
border-radius:6px;
background-color: #EEE;
border: 1px solid #EEE;
margin-left: 24%;
height:auto;
width:620px;
}

這看起來像

在此處輸入圖片說明

這是我整個CSS的CSS規則

我正在使用此身體css規則。 對於我的漸變

整個頁面的CSS規則

html
{
  height:100%;
}

這是在.news-box類之前

body
{
background: rgb(125,126,125); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(125,126,125,1) 39%, rgba(14,14,14,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(39%,rgba(125,126,125,1)), color-stop(100%,rgba(14,14,14,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7d7e7d', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
}

這就是沒有Div時頁面的外觀

在此處輸入圖片說明

有任何解決這個問題的方法嗎?

演示 .....................................

嘿,現在習慣將html and body min height化為100% ,就像這樣

html, body{
min-height:100%;

}

演示版

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM