除了特定父元素之外,如何选择除SASS之外的所有元素?

时间:2014-11-19 19:35:50

标签: css sass

我想对页面上的所有HTML元素进行标准重置(使边距和填充0)除了那些.raw-HTML的子元素。

以下是我无法使用的内容(甚至使用SASS编译)

h1,h2,h3,h4,h5,h6,
p,blockquote,pre,
dl,dd,ol,ul,
form,fieldset,legend,
table,th,td,caption,
hr {

    &:not(.raw-HTML > &) {
        margin: 0;
        padding: 0;
    }
}

2 个答案:

答案 0 :(得分:0)

not不接受多个选择器,因此无法正常工作。我不知道是否有这样做的好方法,但你可以尝试这样的事情:

*:not(.raw-HTML){
    h1,h2,h3,h4,h5,h6,
    p,blockquote,pre,
    dl,dd,ol,ul,
    form,fieldset,legend,
    table,th,td,caption,
    hr {
        margin: 0;
        padding: 0;
   }
}

答案 1 :(得分:0)

在使用次优解决方案后计算出来。

h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
dl,
dd,
ol,
ul,
form,
fieldset,
legend,
table,
th,
td,
caption {
    margin: 0;
    padding: 0;


    .raw-HTML & {
        margin: inherit;
        padding: inherit;
    }
}
相关问题