2010-12-19 116 views
4

我有一個包含兩個浮動元素contentArea和側邊欄的包裝元素。 contentArea的內容最多,因此決定了包裝元素的高度。我想讓側邊欄觸摸包裝div的底邊。我怎麼做。這是一個基本的WordPress博客佈局。使子div與自動高度父div一樣高

HTML:

<div id="wrapper" class="clearfix"> 
    <div id="content"> 
     GROWS REALLY TALL AS HAS SO MUCH CONTENT 
     GROWS REALLY TALL AS HAS SO MUCH CONTENT 
     GROWS REALLY TALL AS HAS SO MUCH CONTENT 
     GROWS REALLY TALL AS HAS SO MUCH CONTENT 
     GROWS REALLY TALL AS HAS SO MUCH CONTENT 
    </div> 
    <div id="sidebar"> 
     WANT'S TO BE AS TALL AS CONTENT. 
     height:100%; /* doesn't work */ 
    </div> 
</div> 

CSS:

#wrapper{ 
    height:auto; 
    width:100%; 
} 
#content{ 
    height:auto; 
    width:625px; 
} 
#sidebar{ 
    height:100%; 
    width:335px; 
} 

感謝所有幫助。

感謝

+0

我不明白,邊欄是觸摸包裝的底部(至少在這個代碼中) – Trufa 2010-12-19 07:49:22

回答

6

that你在找什麼?

+0

是的!非常感謝你......我有一種感覺,我不得不最終訴諸js ......你保存了我的設計......謝謝! – Aayush 2010-12-19 09:28:29

+0

@RCNeil,不,它只是CSS。你不應該使用JavaScript進行樣式設計,除非你不能用CSS來完成。 – 2013-01-11 19:21:58