1 回答

TA貢獻1876條經驗 獲得超5個贊
更新
由于 DOMPDF 尚不支持 Flexbox,因此我提供了一個inline-block
適合您的版本。為了解決您可能遇到的空白問題,我省略了結束語,這不會以任何方式</li>
影響 的有效性。HTML
ul {
padding-top: 8px;
padding-left: 0px;
margin: 0;
list-style: none;
border-top: 2px solid #000000;
display: block;
}
li {
width: 50%;
display: inline-block;
vertical-align: top;
margin-bottom: 4px;
}
.item {
margin-bottom: 10px;
}
.item strong,
.item .text {
display: inline-block;
vertical-align: top;
}
.item strong {
width: 40%;
display: inline-block;
white-space: nowrap;
}
.item strong::after {
content: ':';
}
.item .text {
width: 60%;
padding: 0;
margin: 0;
}
<ul>
<li>
<div class="item">
<strong>My Label</strong><p class="text">My text here</p>
</div>
<li>
<div class="item">
<strong>My Label</strong><p class="text">My text here</p>
</div>
<div class="item">
<strong>My Label</strong><p class="text">My long text here My long text here My long text here My long text here My long text here</p>
</div>
<div class="item">
<strong>My Label</strong><p class="text">My text here</p>
</div>
</ul>
使用inline-block
有時會帶來問題,因為空白區域會成為HTML
渲染的一部分。我會使用 flexbox 來解決這個ul
問題li
。最后,我在 的內容周圍添加了一些標記li
,使其也成為 Flexbox 父級。
ul {
padding-top: 8px;
padding-left: 0px;
margin: 0;
list-style: none;
border-top: 2px solid #000000;
display: block;
width: 99%;
display: flex;
}
li {
flex: 1 0 50%;
margin-bottom: 4px;
display: flex;
flex-direction: column;
}
.item {
display: flex;
margin-bottom: 10px;
}
.item strong {
flex: 4;
white-space: nowrap;
}
.item strong::after {
content: ':';
}
.item .text {
flex: 6;
padding: 0;
margin: 0;
}
<ul>
<li>
<div class="item">
<strong>My Label</strong>
<p class="text">My text here</p>
</div>
</li>
<li>
<div class="item">
<strong>My Label</strong>
<p class="text">My text here</p>
</div>
<div class="item">
<strong>My Label</strong>
<p class="text">My text here</p>
</div>
<div class="item">
<strong>My Label</strong>
<p class="text">My text here</p>
</div>
</li>
</ul>
- 1 回答
- 0 關注
- 233 瀏覽
添加回答
舉報