CSS SASS : 不是选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22650270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SASS :not selector
提问by user2667409
I have a :not
css selector in SASS mixin but it doesn't do anything:
我:not
在 SASS mixin 中有一个css 选择器,但它没有做任何事情:
Code Snippet:
代码片段:
@mixin dropdown-pos($pos:right) {
&:not(.notip) {
@if $comp-tip == true{
@if $pos == right {
top:$dropdown-width * -0.6;
@include tip($pos:$pos);
}
}
}
&.notip {
@if $pos == right {
top: 0;
left:$dropdown-width * 0.8;
}
}
}
The .notip
class is being generated but no CSS is being generated for :not(.notip)
.
在.notip
正在生成的类,但正在为没有生成CSS :not(.notip)
。
回答by Ming
I tried re-creating this, and .someclass.notip
was being generated for me but .someclass:not(.notip)
was not, for as long as I did not have the @mixin tip()
defined. Once I had that, it all worked.
我尝试重新创建它,并且.someclass.notip
正在为我生成但.someclass:not(.notip)
不是,只要我没有@mixin tip()
定义。一旦我有了它,一切都奏效了。
http://sassmeister.com/gist/9775949
http://sassmeister.com/gist/9775949
$dropdown-width: 100px;
$comp-tip: true;
@mixin tip($pos:right) {
}
@mixin dropdown-pos($pos:right) {
&:not(.notip) {
@if $comp-tip == true{
@if $pos == right {
top:$dropdown-width * -0.6;
background-color: #f00;
@include tip($pos:$pos);
}
}
}
&.notip {
@if $pos == right {
top: 0;
left:$dropdown-width * 0.8;
background-color: #00f;
}
}
}
.someclass { @include dropdown-pos(); }
EDIT:http://sassmeister.com/is a good place to debug your SASS because it gives you error messages. Undefined mixin 'tip'.
it what I get when I remove @mixin tip($pos:right) { }
编辑:http : //sassmeister.com/是调试 SASS 的好地方,因为它会为您提供错误消息。Undefined mixin 'tip'.
这是我删除时得到的@mixin tip($pos:right) { }