Css 为什么:not()选择器不是';工作不正常吗?
我对Css 为什么:not()选择器不是';工作不正常吗?,css,sass,less,Css,Sass,Less,我对:not()工作不正常有点问题。在这里,尽管使用了:not(.no破折号)选择器,该样式仍然适用: HTML 简单标题 SCSS div:not(.no-dash) { h2 ,h3, h4, h5, h6 { margin-bottom: 36px; &::after { content: ""; display: block; position: absolute;
:not()
工作不正常有点问题。在这里,尽管使用了:not(.no破折号)
选择器,该样式仍然适用:
HTML
简单标题
SCSS
div:not(.no-dash) {
h2 ,h3, h4, h5, h6 {
margin-bottom: 36px;
&::after {
content: "";
display: block;
position: absolute;
bottom: -10px;
left: 0;
width: 45px;
height: 3px;
background-color: $color_yellow;
}
}
}
:not(.no-dash) {
h2, h3, h4, h5, h6 {
&:not(.no-dash) {
margin-bottom: 36px;
&::after {
content: "";
display: block;
position: absolute;
bottom: -10px;
left: 0;
width: 45px;
height: 3px;
background-color: $color_yellow;
}
}
&.text-center:not(.no-dash) {
&::after {
left: 50%;
transform: translate(-50%);
}
}
&.text-right:not(.no-dash) {
&::after {
left: auto;
right: 0;
}
}
}
}
我的真实代码: HTML
简单地说你的日常生活:
联合国秘书处?
联合国解决方案
你在哪里?
我们的雅芳双!
Votre安瓿烤架?
我们的德文郡是前卫的!
你能给我一堆酒吗?
我们的德文郡是前卫的!
你是不是要去巴黎?
我们的pouvons改进了vos文件!
等
SCSS
div:not(.no-dash) {
h2 ,h3, h4, h5, h6 {
margin-bottom: 36px;
&::after {
content: "";
display: block;
position: absolute;
bottom: -10px;
left: 0;
width: 45px;
height: 3px;
background-color: $color_yellow;
}
}
}
:not(.no-dash) {
h2, h3, h4, h5, h6 {
&:not(.no-dash) {
margin-bottom: 36px;
&::after {
content: "";
display: block;
position: absolute;
bottom: -10px;
left: 0;
width: 45px;
height: 3px;
background-color: $color_yellow;
}
}
&.text-center:not(.no-dash) {
&::after {
left: 50%;
transform: translate(-50%);
}
}
&.text-right:not(.no-dash) {
&::after {
left: auto;
right: 0;
}
}
}
}
:not()
选择器在此不工作,因为您的h1
,h2
,h3
。。。嵌套在多个div
中,并且并非所有的类都具有排除类。你自己看看:
div:not(.no破折号)h2{
颜色:红色;
}
嵌套在多个div中
嵌套在单个div中
没有课
它按预期工作。检查它。在第一个示例中缺少一个结束语}
?确实是“johannchopin”,它工作正常,但为什么不为我的:(没有“Andersonola”所有的}
都出现了。我会发布我真正的代码。