【发布时间】:2022-02-08 14:00:24
【问题描述】:
如何使用 SCSS 缩短这个具有 CSS 伪元素的 CSS?
.bar-color1 {
background: #28A745;
position: absolute;
top: 0; bottom: 0; left: 0;
&::after {
color: #28A745;
content: url("../../assets/images/arrow.png");;
display: inline-block !important;
width: 0;
height: 0;
position: absolute;
right: 6px;
top: -6px;
}
}
.bar-color2 {
background: #28A745;
position: absolute;
top: 0; bottom: 0; left: 0;
&::after {
content: "" !important;
}
}
如你所见,两者都有这些共同的风格
background: #28A745;
position: absolute;
top: 0; bottom: 0; left: 0;
【问题讨论】: