Html 如何覆盖内容 div 中的 CSS 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2940191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:16:24  来源:igfitidea点击:

How to override a CSS class within a content div

htmlcssclassoverriding

提问by Amirouche Douda

I want to reimplement the property margin-right in a bloc whitin a content.

我想在一个内容块中重新实现属性 margin-right。

this is the content id css:

这是内容 ID css:

#content h2 {
      margin-right:2px;
            }

this is the bloc class css:

这是集团类css:

    .bloc h2 {
margin-right:0px;
                }

I want the margin-right of the ".bloc" css fires rather than the "#content" css

我想要“.bloc”css 的边距右侧而不是“#content”css

回答by Marc Tidd

Try !important, like this:

试试 !important,像这样:

.bloc h2 
{
    margin-right:0px !important;
}

回答by greg0ire

You could try this :

你可以试试这个:

#content .bloc h2
{
    margin-right: 0;
}

I'm not sure I understood your question perfectly well, especially the last sentence...

我不确定我是否完全理解你的问题,尤其是最后一句话......