<分区>
我正在尝试使用 SASS 的嵌套功能来连接两个类,但不知道该怎么做。
这是 HTML:
<section class="a">
<div class="b">
<div class="c date">some date</div>
</div>
</section>
这是我当前的 SASS:
.a .c
display: inline-block
.date
width: 50px
它创建以下 CSS:
.a .c {
display: inline-block;
}
.a .c .date {
width: 50px;
}
但这行不通。浏览器希望“date”和“string-long”嵌套在“c”类下,而不是它们都存在于同一个 HTML 标记中。
我需要的是这个(.c 和 .date 之间没有空格 => .c.date):
.a .c {
display: inline-block;
}
.a .c.date {
width: 50px;
}
我该怎么做?