$typeset: 'card'
$exercise-type: 'Choise'
&[style]
display: block
> div.shade-btn
display: flex
> div
display: flex
position: absolute
top: -26px
z-index: 3
> span
height: 26px
padding: 3px 5px
cursor: pointer
@if(&exercise-type == 'Choise')
font-size: 12px !important
@else
font-size: 14px !important
这是我写的,我想通过判断 span 的上上级的 div 的 typeset 和 exercise-type 属性来设置 span 标签的字体大小,但是按照我这么写的话他不管属性对不对字号都是 12,想问问大佬们这个该怎么写啊,我这个是第一次接触 sass
1
crs0910 2021-08-18 19:35:59 +08:00
```sass
@use "sass:selector" @mixin if-root-is($selector) $current-sequences: & //.p .c $result: () @each $sequence in $current-sequences // [.p, .c] $current: nth($sequence, -1) // .c $root: nth($sequence, 1) // .p $unify-root: selector.unify($root, $selector) // .p.x $result: append($unify-root, $current) @at-root #{$result} @content .p .c color: red @include if-root-is('.p12') color: green ``` |