我基本上是一個窗體(屏幕截圖:http://mason.gmu.edu/~vnguyenl/form.jpg),其中有2列。標籤欄和輸入欄。標籤邊是一個div,它有自己的bg顏色,和輸入欄一樣。我試圖做到這一點,如果一方的文字多於另一方的文字則會匹配它的高度。現在,如果一方比另一方大,則存在差距。將不勝感激任何幫助!謝謝。CSS製作內部div匹配外部div高度
該窗體的HTML如下所示:
<div class="formRow">
<div class="labelColumn">Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: Last Name: <span class="required">*</span></div>
<div class="contentcolumn">
<input class="textBox300" type="text" id="last_name" tabindex="1" />
</div>
</div>
的CSS如下:
#pt-profile-form .labelColumn, .labelColumn2 {
font-weight:bold;
float:left;
width:300px; /* Width of left column */
margin-left:0px;
background:#f0f4f7;
text-align:left;
padding:5px;
padding-left:14px;
display:block;
white-space:normal;
position:relative;
clear:both;
}
#pt-profile-form .formRow { clear:both; height:100%; }
#pt-profile-form .contentcolumn, .contentcolumn2 {
margin-left:320px; /* Set left margin to LeftColumnWidth */
background-color:#eae9d7;
padding:5px;
text-align:left;
vertical-align:middle;
position:relative;
}
#pt-profile-form .labelColumn, .contentcolumn {
/*height:30px;*/
min-height:30px;
height:100%;
}
#pt-profile-form .labelColumn2, .contentcolumn2 { /* column properties for <textarea> */
/*height:100px;*/
height:100%;
}
退房:http://www.quirksmode.org/ css/clearing.html –
這也是:http://www.alistapart.com/articles/prettyaccessibleforms –