簡體   English   中英

div背景圖片和高度不起作用

[英]Div background image & height not working

我有一個div主文件,我已將其內容和側邊欄包裹起來。 我已將#main分配為具有背景圖片和1200px的最小高度。

在Google Chrome和Firefox中,當我檢查源代碼時,檢查div沒有任何屬性。 因此div的背景圖片和高度也不起作用。

<!--Main content layout -->
#main {
clear:both;
position: relative;
min-height: 1200px;
background-image:url(images/white.png);
background-repeat: repeat-x;

}

.sidebar1 {
float: right;
width: 20%;
padding-bottom: 10px;
margin-top: 20px;
}
 .content {
padding: 10px 0;
width: 76%;
float: left;
margin-top: 20px;

}

該站點地址是: http : //www.tibetskyvillage.org/

非常感謝其他人對此的關注。 我一直在使用這種方法,由於某種原因,這次失敗了。

注釋<!--Main content layout -->不是有效的CSS注釋,而是HTML注釋,但會引起解析錯誤。

在此處輸入圖片說明

看截圖,我發現您的布局有些混亂,要解決此問題或解決您的問題的方法是:不要在CSS中提供圖片作為背景,而在html中提供圖片

<img width="1360" height="675" src="images/bg0.jpg" class="wraper">
<div id="main">Your content</div>

為圖像添加樣式,並以

.wraper {
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
}

#main{
position: absolute;
min-height: 1200px;
width:100%;
}

暫無
暫無

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

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