【问题标题】:Overiding the CSS value to default setting [duplicate]将CSS值覆盖为默认设置[重复]
【发布时间】:2016-05-03 04:21:02
【问题描述】:
width:16.5%;
float:left;

如果我将 CSS 属性设置为上面的代码。如何“重置”它?

我希望它没有浮动和宽度设置。我使用初始还是继承?

@media (max-width: 475px) and (min-width: 320px) {
#myid {
width:initial;
float:none;
}
}

【问题讨论】:

    标签: html css


    【解决方案1】:

    不幸的是,您无法在不知道其初始值的情况下跨浏览器重置它。您需要查阅规范并查看属性的默认值。

    initial 不受 IE 支持。

    【讨论】:

      【解决方案2】:

      你可以这样重启它:

      #myid{
       width: auto;
       float: none;
      }
      

      【讨论】:

        【解决方案3】:

        根据https://www.w3.org/TR/css3-values/#common-keywords

        The initial keyword represents the value specified as the property’s initial value. The inherit keyword represents the computed value of the property on the element’s parent.
        

        如果您不需要 IE 支持,可以使用 initial - http://caniuse.com/#search=initial

        但如果您需要,可以参考 w3schools 的default value

        默认width 属性值为auto - http://www.w3schools.com/cssref/pr_dim_width.asp

        默认float 属性值为none - http://www.w3schools.com/cssref/pr_class_float.asp

        【讨论】:

          【解决方案4】:

          这取决于您设置的参数。对于您的情况,以下内容将起作用:

          #myid {
            width:auto;
            float:none;
          }
          

          使用某些值时应考虑浏览器支持。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2015-06-30
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-02-21
            • 1970-01-01
            • 2011-12-20
            相关资源
            最近更新 更多