Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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 - Fatal编程技术网

如何取消上游CSS声明?

如何取消上游CSS声明?,css,Css,以下声明位于我的CSS文件顶部: * { margin: 0; padding: 0; border: 0; } …几乎是我想要的,但不完全是。更接近标志的是以下“幻想CSS”: 我试着用你的眼睛来模拟这个幻想 * { margin: 0; padding: 0; border: 0; } button { border: initial; } …毫无用处。(我推测,至少对于按钮,边框属性的初始值实际上是0,或者实际上是等效值。) 当然,在没有边框的情况下,我可

以下声明位于我的CSS文件顶部:

* {
  margin: 0;
  padding: 0;
  border: 0;
}
…几乎是我想要的,但不完全是。更接近标志的是以下“幻想CSS”:

我试着用你的眼睛来模拟这个幻想

* {
  margin: 0;
  padding: 0;
  border: 0;
}

button {
  border: initial;
}
…毫无用处。(我推测,至少对于
按钮
边框
属性的
初始
值实际上是
0
,或者实际上是等效值。)

当然,在没有
边框的情况下,我可以找到
边框对于
按钮
的值:0声明,然后显式重置此值;e、 g

* {
  margin: 0;
  padding: 0;
  border: 0;
}

button {
  border: 2px outset rgb(240, 240, 240);
}
…但这肯定不是取消早期的
边框:0声明。首先,
按钮{border:…;}
声明的实际值必然会随着浏览器、操作系统等的不同而变化

有没有办法真正取消以前的CSS声明?瞧,有没有什么方法可以在CSS中表达(或实现)某种语义上与我上面展示的“幻想CSS”等价的东西


(当然,我意识到我总是可以放弃使用
*
作为
边框的选择器:0;
声明,只需使用一个选择器,该选择器包含除
按钮以外的所有html5标记,但这并不能回答我的问题,它只是绕过了它。因此,严格地说,这一解决方法是多余的就这篇文章而言。除此之外,我还有一些关于它的疑问。)

只需使用
:not()
选择器(暗示
*
):

:非(按钮){
边距:0;/*应用于除*/
}
阅读更多信息,请重复阅读。 使用以下命令代替*:

    html, body, body div, span, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
     abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
     small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
        fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
        article, aside, canvas, details, figcaption, figure,
        footer, header, hgroup, menu, nav, section, summary,
        time, mark, audio, video {
                  margin: 0;
                  padding: 0;
                 border: 0;
                  font-size: 100%;
          vertical-align: baseline;
}
您可以添加或删除其他标记

对于更复杂的Inicialitazion,我建议您使用html5doctor.com重置样式表,您可以在这里找到它

甚至比重置更好:(保留默认值,但删除用户代理之间的差异)
:not(button) {
    margin: 0; /* applied to all elements except <button> */
}
    html, body, body div, span, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
     abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
     small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
        fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
        article, aside, canvas, details, figcaption, figure,
        footer, header, hgroup, menu, nav, section, summary,
        time, mark, audio, video {
                  margin: 0;
                  padding: 0;
                 border: 0;
                  font-size: 100%;
          vertical-align: baseline;
}