2013-10-18 83 views
-1

由於標頭設計img #searchbar-container,我無法讓.content-panel#panel-design漂浮在.content的右側。 我已經嘗試使用z-index不同的值。 我想雖然具有上述的div #searchbar-containerimg from header div不在內容div前

<body> 
     <div class="header"> 
      <img id="searchbar-container" src="images/searchbar1.png"> 
     </div> 
     <div class="content"> 
      <div class="sidebar"></div> 
      <div class="content-panel"> 
       <div id="panel-design"></div> 
        <!--main content here--> 
      </div> 
     </div> 
</body> 

的CSS放置.content-panel#panel-design.content右側:

.content { 
    position: relative; 
    max-width: @width; 
    height: 768px;; 
    margin: 0 auto; 
    padding: 0; 
    } 
     .content-panel { 
     position: absolute; 
     float: right; 
     margin: 0; 
     padding: 0; 
     width: 753px; 
     height: 100%; 
     background-color: blue; 
     z-index: -2; 
    } 
    #panel-design{ 
     float: right; 
     width: 685px; 
     height: 375px; 
     background-color: red; 
     z-index: -1; 
    } 
    .sidebar{ 
     width: 285px; 
     height: 100%; 
     margin: 0; 
     padding: 0; 
    } 

不能發佈整個事情。但這是我需要實現的,基本上上面的灰色圖像是#searchbar-container,而Depp的圖片是.content-panel前面的#panel-design

enter image description here

到目前爲止,這是我的頁面的樣子:

enter image description here

藍格是.content-panel

紅格爲#panel-design

灰色img以上是#searchbar-container

.content沒有背景顏色,但它的大小是合格#searchbar-container

+3

'位置:absolute'和'浮動:right'不在一起工作,僅供參考。挑一個或另一個。另外,你沒有向我們展示你所有的CSS,所以知道這很難。 –

+0

你能張貼想要的結果嗎? – j08691

+0

@cale_b這是一個錯字,我注意到了。 – OneScrewLoose

回答

1

所以我明白從你們的問題是,你要#searchbar-container重疊您#panel-design曲線。

這樣做的一種方法是使.header div固定,但您可能不希望這樣做,因爲這樣它就獨立於滾動。

另一種方式,我想出了利用absolute位置可以看到小提琴here

+0

它當然是在'#searchbar-container'下面,但是''content'div'在頁面中間是980px,'.content'用作頁面包裝器,它保存所有內容(除了header)在瀏覽器中間 – OneScrewLoose

+0

是'.content'的位置相對嗎? – lazyprogrammer

+0

是的,我更新了 以上的css代碼,如果我刪除'#panel-design',一切都在適當的位置。 'z-index'不起作用,不知道爲什麼。 – OneScrewLoose