简体   繁体   English

CSS-在单独行上带有dt和dd的DL样式定义列表

[英]CSS - DL styling definition list with dt and dd on seperate rows

I am trying to style up a definition list with on top row and there corresponding dd's on sitting directly below on a seperate line 我正在尝试在顶部行上设置定义列表的样式,并且在单独行的正下方坐在相应的dd上

HTML 的HTML

<dl>
    <dt>Term 1</dt>
    <dd>Definition 1</dd>

    <dt>Term 2</dt>
    <dd>Definition 2</dd>

    <dt>Term 3</dt>
    <dd>Definition 3</dd>
</dl>

CSS 的CSS

dl {
    margin: 0;
    padding: 0 0 30px;
}
dt, dd {
    float: left;
    margin: 0;
    width: 33%;
}

I need them to sit something like below: 我需要他们坐在下面这样: 在此处输入图片说明

Without a containing element (which <dl> does not provide or allow for) around each <dd> and <dt> pair, and without resorting to likely-brittle absolute positioning, I think you're going to find that you'll need different markup to accomplish that layout. 在每个<dd><dt>对周围没有包含元素( <dl>不提供或不允许)的元素,并且不求助于可能的脆性绝对定位,我想您会发现您需要不同的标记来完成该布局。

It's not quite as semantically clean as your original markup, since it splits up the <dl> into three separate definition lists, but here's a working fiddle . 它在语义上不如您的原始标记干净,因为它将<dl>分为三个单独的定义列表,但这是一个有效的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM