【发布时间】:2021-11-08 09:25:17
【问题描述】:
我使用 dt 和 dd 创建纸质表单。
dt 宽度应该匹配单词,dl 应该匹配剩余空间
现在我手动调整每一行,如何使用 css 自动调整?
div {
width: 200px;
}
/* dl dt dd same line */
dl {
width: 100%;
overflow: hidden;
padding: 0;
margin: 0
}
dt {
float: left;
/* adjust the width; make sure the total of both is 100% */
padding: 0;
}
dd {
float: left;
/* adjust the width; make sure the total of both is 100% */
margin: 0;
box-sizing: border-box;
border-bottom: 1px solid black;
}
dl dt:nth-of-type(1) {
width: 36%;
}
dl dd:nth-of-type(1) {
width: 64%;
}
dl dt:nth-of-type(2) {
width: 26%;
}
dl dd:nth-of-type(2) {
width: 74%;
}
dl dt:nth-of-type(3) {
width: 14%;
}
dl dd:nth-of-type(3) {
width: 86%;
}
<div>
<dl>
<dt>aaabbbccc:</dt>
<dd> </dd>
<dt>aaabbb:</dt>
<dd> </dd>
<dt>aaa:</dt>
<dd> </dd>
</dl>
</div>
【问题讨论】: