8
有时
14
).
1
宽度为两位数。我的目标不是完美(数字通常有不同的宽度),而是要说一些沿着
<span class="el" width_of_text_for_this_element="2em;">1</span>
.clock {
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 20px;
align-items: center;
width: 400px;
}
.el {
display: flex;
justify-content: center;
align-items: center;
width: 200px;
height: 200px;
font-size: 120px;
background-color: black;
color: white;
font-family: sans-serif;
font-weight: bolder;
}
<div class="clock">
<span class="el">1</span>
<span class="el">18</span>
</div>
我相信我正在寻找的是一种将样式应用于元素内容(而不是元素本身)的方法,但我不确定。