Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS目标类的第一级“;“世界其他地区”;只有嵌套的,而不是嵌套的_Css_Css Selectors_Sass - Fatal编程技术网

CSS目标类的第一级“;“世界其他地区”;只有嵌套的,而不是嵌套的

CSS目标类的第一级“;“世界其他地区”;只有嵌套的,而不是嵌套的,css,css-selectors,sass,Css,Css Selectors,Sass,是否可以只针对类的第一级。行 您的代码编译为以下两个选择器: .personal-details > .row .columns:first-child .personal-details > .row .columns:last-child 您正确地瞄准了第一级.row元素,但因为嵌套的.columns元素是它们自己的.row父元素和第一级.row父元素的后代,所以它们也是匹配的 因此,您需要添加更多的组合器: .personal-details > .row{

是否可以只针对类的第一级。行


您的代码编译为以下两个选择器:

.personal-details > .row .columns:first-child
.personal-details > .row .columns:last-child
您正确地瞄准了第一级
.row
元素,但因为嵌套的
.columns
元素是它们自己的
.row
父元素和第一级
.row
父元素的后代,所以它们也是匹配的

因此,您需要添加更多的
组合器:

.personal-details > .row{
    > .columns:first-child{
        padding-left:0;
    }
    > .columns:last-child{
        padding-right: 0;
    }
}
这将生成以下选择器,这些选择器将仅匹配顶级
。列
元素:

.personal-details > .row > .columns:first-child
.personal-details > .row > .columns:last-child

请用你正在使用的预处理器标记你的问题,否则有人会对你抱怨嵌套规则是无效的CSS。老实说,我不想让纯CSS问题标记为Sass。只需发布编译后的CSS。
.personal-details > .row .columns:first-child
.personal-details > .row .columns:last-child
.personal-details > .row{
    > .columns:first-child{
        padding-left:0;
    }
    > .columns:last-child{
        padding-right: 0;
    }
}
.personal-details > .row > .columns:first-child
.personal-details > .row > .columns:last-child