我想在 div 中间画一条线。在下图中,该线应位于红色框的中间。
我正在尝试使用行高来做到这一点,但无法做到。
这是代码:
HTML/CSS:
.wrap {
text-align: center;
margin: 20px;
}
.links {
padding: 0 10px;
border-top: 1px solid #000;
height: 1px;
line-height: 0.1em;
}
.dot {
width: 20px;
height: 20px;
background: red;
float: left;
margin-right: 150px;
position: relative;
top: -10px;
}
<div class="wrap">
<div class="links">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</div>
演示: https ://jsfiddle.net/nkq468xg/
原文由 sam 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以在 ---
Flexbox
上使用 ---links
并且对于行,您可以在 wrap 元素上使用:before
伪元素。