【发布时间】:2020-04-07 21:03:45
【问题描述】:
这是我想要得到的输出:
这里是代码:https://jsfiddle.net/t5ewp8ax/
// html
<p class="movie-category">
<span>Sentimental</span>
<span>Romantic</span>
<span>Dramedy</span>
</p>
// scss
.movie-category {
font-size: 3em;
display: inline-flex;
justify-content: space-between;
background: blue;
> span:not(:last-child) {
$distance: 1em;
$half-distance: $distance / 2;
margin: 0 $distance 0 0;
position: relative;
}
> span:not(:last-child)::after {
$size: .2em;
$half-size: $size / 2;
content: '';
position: absolute;
top: calc(50% - $half-size);
left: calc(100% + $half-distance - $half-size);
display: block;
width: $size;
height: $size;
border-radius: 50%;
background: red;
}
}
似乎是这样的:
> span:not(:last-child) {
$distance: 1em;
margin: 0 $distance 0 0;
}
被正确解析为margin: 0 1em 0 0;。但是
> span:not(:last-child)::after {
left: calc(100% + $half-distance - $half-size);
}
没有被解析为left: calc(100% + .5em - .1em);。为什么?我做错了什么?
顺便说一句,如果有更简洁的代码可以提供该输出,我们将非常欢迎
【问题讨论】: