2011-05-26 120 views
-1

我有一個CSS佈局,如在this圖片。圖片側邊欄

我想達到以下行爲

IMG應始終低於左側邊欄(如圖片)。問題是,左側邊欄包含摺疊/展開鏈接的列表,當您展開它時,img與左側邊欄重疊並且文本不可讀。

謝謝

+1

而且您使用的HTML是什麼?你有什麼嘗試?什麼地方出了錯? – 2011-05-26 19:08:47

+0

你說不要解決它 - 它已經在其他地方解決了,但這不是對問題的修改 - 意味着你知道它在發佈之前已經解決了。那麼爲什麼發佈呢? – 2011-05-26 19:17:51

+0

我將兩個部分拆分爲[原始](http://stackoverflow.com/questions/6138007/difficult-css-positioning-problem)問題以降低混淆。第一部分解決了。看起來部分是獨立的。 – xralf 2011-05-26 19:20:20

回答

1

HTML

<div id="container"> 
    <div id="header">ert</div> 
    <div id="left-sidebar">sdfsdfsdft 
     <div id="img">IMG</div></div> 
    <div id="right-sidebar">ert</div> 
    <div id="content">aaert</div> 
</div> 

CSS:

#container { 
    width:100%; 
    height:100%; 
} 
#header { 
    background: url("img.png") red; 
    background-repeat: no-repeat; 
    background-position: right top; 
    height: 125px; 
    margin:-10px -10px 0px -10px; 
} 

#left-sidebar { 
    left: 0; 
    height:2000px; 
    width:200px; 
    background-color: yellow; 
    position: fixed; 
} 

#right-sidebar { 
    right:0; 
    position: fixed; 
    width:200px; 
    height:2000px; 
    background:green; 
} 
#img { 
    border:1px solid; 
    position: relative; 
    top:5px; 
    left:0px; 
    margin-left:10px; 
    width:175px; 
    height:175px; 
} 

#content { 
    margin-left:-10px; 
    position: absolute; 
    margin:auto; 
    top:130px; 
    left:208px; 
    right:208px; 
    border:1px solid; 
    Height:100%; 
}