【问题标题】:Overriding the CSS in the style tag [duplicate]覆盖样式标签中的 CSS [重复]
【发布时间】:2014-10-28 20:11:56
【问题描述】:

我有以下由 jQuery Mobile 框架生成的 HTML 和 CSS。我无法控制生成的 HTML。我只能设计它们。

<div class="ui-popup-container slideup in ui-popup-active" id="productSummaryOverlay-popup" tabindex="0" style="max-width: 1201px; top: 0px; left: 17px;">

我想忽略或删除 style 属性中的所有内容,因为它无法全屏显示,并且还提供了我不想要的边距。

如何忽略 style 属性?

【问题讨论】:

  • 你试过使用 !important 吗?
  • 可能有点 JavaScript? .setAttribute("style", "");
  • 这里解释得很好:stackoverflow.com/questions/19366227/…,希望这可以帮助你[1]:
  • 谢谢大家!我按照建议使用 !important 解决了这个问题。谢谢!

标签: css jquery-mobile


【解决方案1】:

您可以使用 !important 设置具有更高优先级的样式 喜欢

.slideup{
  top: 50px !important;
}

您还可以使用 jQuery(和 js)控制样式 - 例如 setAttribute('style', ... 或 .style 属性

【讨论】:

    【解决方案2】:

    在行尾使用 !important:

    #productSummaryOverlay-popup {
        max-width: none !important;
        top: auto !important;
        left: auto !important;
    }
    

    【讨论】:

      猜你喜欢
      • 2019-12-10
      • 2018-09-22
      • 2019-03-04
      • 2020-01-01
      • 1970-01-01
      • 2013-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多