How do I use a wildcard asterisk CSS selector in SASS? [closed]

…衆ロ難τιáo~ 提交于 2019-12-06 12:43:43

There's little here that SASS can help you with. You do not need vendor prefixes. Just write

*, ::before, ::after {
  box-sizing: border-box;
}

* {
  line-height: 1;
}

Whether to write *::before or ::before is a matter of personal preference.

The I-must-use-SASS mentality would be to say I must write the

*::before 

rule as

* { 
  &::before

because I must use nesting, no matter what, just because I can. Actually, not. Your CSS is often much cleaner with less (or zero) nesting. (Often it's clearer with no SASS at all, but that's a topic for another day.)

How do I use a * CSS wildcard selector when using SASS?

There is nothing special about the * to SASS. It's just another selector. You use it like you use any other selector.

*
 ...
  &:before, &:after
    ...

& stands for the current selector. e.g. foo { .bar { } } is foo .bar; foo { &.bar { } } matches foo.bar.

@mixin boxSixing($boxType:border-box){
  -webkit-box-sizing: $boxType;
  -moz-box-sizing: $boxType;
  box-sizing: $boxType;
}
* {
  @include boxSixing;
  line-height: 1;
  &:after,&:before{
    @include boxSixing;
  };
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!