使dt和dd的高度相同,以便在dt上应用背景色



我有这个标记:

<dl class="item_tabs_details">
    <dt>Lot Size</dt>
    <dd>324 sq. meters</dd>
    <dt>Baths</dt>
    <dd>2</dd>
    <dt>Full Description</dt>
    <dd>
        <p>
        House & Lot for Sale/Rent, 4BR, 1165sqm. PHP65M/200K/MO. (Pasig) Beautiful
        house with 4 bedrooms, den/office, entertainment room, covered lanai, swimming
        pool and manicured garden.
        </p>
    </dd>
</dl>

使用这种样式:

dl.item_tabs_details dt, dl.item_tabs_details dd{
    float:left;
    padding: 10px;
    border-bottom: 1px solid #eee;
}
dl.item_tabs_details dt{
    width:130px;
    background-color: #ccc;
    color: #000;
}
dl.item_tabs_details dd{
    width:760px;
    min-height: 12px;
}

如果dd跨越1行以上,我希望dt的高度与dd相同,这样我就可以在没有一些"洞"的情况下为其应用背景色。

这里没有"简单的CSS修复"。

在这种情况下,我可能会使用table,因为它看起来确实有点像表格数据(它使解决问题变得非常容易)。

http://jsfiddle.net/UvPGG/

<table class="item_tabs_details" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="row">Lot Size</th>
    <td>324 sq. meters</td>
  </tr>
  <tr>
    <th scope="row">Baths</th>
    <td>2</td>
  </tr>
  <tr>
    <th scope="row">Full Description</th>
    <td>House &amp; Lot for Sale/Rent, 4BR, 1165sqm. PHP65M/200K/MO. (Pasig) Beautiful house with 4 bedrooms, den/office, entertainment room, covered lanai, swimming pool and manicured garden.</td>
  </tr>
</table>
.item_tabs_details {
    width: 890px
}
.item_tabs_details td, .item_tabs_details th {
    padding: 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top
}
.item_tabs_details th {
    width: 130px;
    background: #ccc;
    text-align: left;
    font-weight: normal
}

最新更新