【发布时间】:2022-12-29 00:11:16
【问题描述】:
我有一个按钮,标签绝对位于下方。
我希望标签不换行而是全部呈现在一行上。我知道我可以用 width: max-content 或 overflow: visible 做到这一点。
但与此同时,我希望标签以按钮为中心,这是我无法找到的方法,除非我将标签换行。
button {
position: relative;
width: 40px;
height: 40px;
background: #E30202;
color: black;
border-radius: 14px;
}
span {
position: absolute;
top: calc(45px);
left: 0;
font-size: 12px;
color: black;
width: 100%;
pointer-events: none;
/* width: max-content; */
}
<button>
<span>Label Line</span>
</button>
【问题讨论】: