【问题标题】:Remove an inline width style setting with CSS [duplicate]使用 CSS 删除内联宽度样式设置 [重复]
【发布时间】:2016-08-04 05:06:56
【问题描述】:

我有一个如下所示的 div:

<div class="wtHolder" style="width:41.66%; height:150px; position:relative;">

我可以在 css 中为 wtHolder 类添加一些东西来删除 width:41.66% 吗?

(如果您想了解我为什么需要这样做的背景,请参阅question。)

【问题讨论】:

  • 你试过经常被诽谤的!important吗?
  • @j08691 - 我做到了。这让我很接近:.wtHolder {width: auto !important;}(我不知道auto 选项。)

标签: css


【解决方案1】:

是的,您可以使用 !important 覆盖它:

.wtHolder {
    width: 100px !important;
}

【讨论】:

    【解决方案2】:

    这是一个技巧,但你实际上可以使用!important

    .wtHolder{
      width:100% !important;
      background-color:black
    }
    &lt;div class="wtHolder" style="width:41.66%; height:150px; position:relative;"&gt;

    【讨论】:

      猜你喜欢
      • 2011-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-30
      相关资源
      最近更新 更多