css,禁用显示:无;

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4009894/
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 23:01:18  来源:igfitidea点击:

css, disable display: none;

css

提问by lolalola

I have this situation in my code:

我的代码中有这种情况:

<!-- This is the global CSS file -->
<style type="text/css">
#show_div{
    display: none;
}
</style>
<!-- This is the local CSS file (only in this page)-->
<style type="text/css">
#show_div{
    /* However to disable display: none;*/  
}
</style>
<body>
<div id = "show_div">
    Text text
</div>

I usually need to hide this element, but on one page, I need to show it. In global css file I have:

我通常需要隐藏这个元素,但在一页上,我需要显示它。在全局 css 文件中,我有:

#show_div{
    display: none;
}

How can I disable display: none;? I can not use jQuery, $('#show_div').show();(or JavaScript).

我怎样才能禁用display: none;?我不能使用 jQuery $('#show_div').show();(或 JavaScript)。

Thanks

谢谢

If you do not understand my problem, then I apologize. I can try to explain again.

如果你不明白我的问题,那么我道歉。我可以再解释一下。

回答by Jason

Change the body class or id of the page you want it to be visible on

更改您希望它在其上可见的页面的正文类或 id

<style>
#show_table #show_div{
display:block!important;
}
</style>


<body id='show_table'>
<div id='show_div'>
text text 
</div>

回答by Nick Craver

Use display: blockto get the default displayfor a <div>element, like tis:

使用display: block获取默认display<div>元素,就像那朵:

#show_div { display: block; }

回答by Quentin

Set it to a different value, but it sounds like you'd be better off just including the content in the page you want it to appear in instead of putting it everywhere and hiding it.

将其设置为不同的 value,但听起来您最好将内容包含在您希望它出现的页面中,而不是将其放在任何地方并隐藏它。

回答by lu-bhz

Use !importantin front of your style on the single page to override previous style definitions.

!important在单个页面上的样式前面使用以覆盖以前的样式定义。

#show_div {
display:block !important;
}