[英]css !important doesn't work & inline-block changes to block
Sorry if this is a duplicate post.抱歉,如果这是重复的帖子。 I hadn't found the answer yet in a few similar posts.
我还没有在一些类似的帖子中找到答案。
This is my website's HTML:这是我网站的 HTML:
.navbar-block{ display: inline-block; margin-left: 5px; margin-right: 5px; }
<div id="navbar" style="background-color: #393939; position: relative; top: -8px; left: -8px; width: 100%; height: 37px; border: 8px solid #393939;"> <div id="logo-container" class="navbar-block"> <a href="/questions" style="color:rgba(0,0,0,0);"> <p style="font-size: 25px; color: #B8A184;" class="no-select">JFJudge</p> </a> </div> <div id="navbar-question" class="no-select navbar-block"><p style="font-size: 14px; color: #ffffff; transform: translateY(-1px);">Questions</p></div> </div>
However, the styles inline-block
margin-left
margin-right
all don't seem to work.但是,styles
inline-block
margin-left
margin-right
似乎都不起作用。 I checked the display style of the element using a console script.我使用控制台脚本检查了元素的显示样式。 It seems like it has the
block
style instead.似乎它具有
block
样式。
The solution was to put inline CSS in the element logo-container
and navbar-question
.解决方案是将内联 CSS 放入元素
logo-container
和navbar-question
中。
I'm trying to solve the problem by only editing the CSS stylesheet.我试图通过仅编辑 CSS 样式表来解决问题。 I also tried:
我也试过:
.navbar-block{
display: inline-block !important;
margin-left: 5px !important;
margin-right: 5px !important;
}
It still doesn't work.它仍然不起作用。
Anything I should try now?我现在应该尝试什么? Thank you.
谢谢你。
Note: I'm using Django localhost to test the HTML, and the stylesheet is put in the static folder.注意:我使用 Django localhost 来测试 HTML,样式表放在 static 文件夹中。
Sorry if this is a duplicate post.抱歉,如果这是重复的帖子。 I hadn't found the answer yet in a few similar posts.
在一些类似的帖子中,我还没有找到答案。
This is my website's HTML:这是我网站的HTML:
.navbar-block{ display: inline-block; margin-left: 5px; margin-right: 5px; }
<div id="navbar" style="background-color: #393939; position: relative; top: -8px; left: -8px; width: 100%; height: 37px; border: 8px solid #393939;"> <div id="logo-container" class="navbar-block"> <a href="/questions" style="color:rgba(0,0,0,0);"> <p style="font-size: 25px; color: #B8A184;" class="no-select">JFJudge</p> </a> </div> <div id="navbar-question" class="no-select navbar-block"><p style="font-size: 14px; color: #ffffff; transform: translateY(-1px);">Questions</p></div> </div>
However, the styles inline-block
margin-left
margin-right
all don't seem to work.但是,样式
inline-block
margin-left
margin-right
似乎都不起作用。 I checked the display style of the element using a console script.我使用控制台脚本检查了元素的显示样式。 It seems like it has the
block
style instead.似乎它具有
block
样式。
The solution was to put inline CSS in the element logo-container
and navbar-question
.解决方案是将内联CSS放入元素
logo-container
和navbar-question
。
I'm trying to solve the problem by only editing the CSS stylesheet.我试图通过仅编辑CSS样式表来解决该问题。 I also tried:
我也尝试过:
.navbar-block{
display: inline-block !important;
margin-left: 5px !important;
margin-right: 5px !important;
}
It still doesn't work.它仍然不起作用。
Anything I should try now?我现在应该尝试什么吗? Thank you.
谢谢你。
Note: I'm using Django localhost to test the HTML, and the stylesheet is put in the static folder.注意:我正在使用Django localhost来测试HTML,并将样式表放在静态文件夹中。
In my case it was a JS function running onLoad that changed the display... I can not believe we can have answers to such weird questions in SO:)就我而言,是运行 onLoad 的 JS function 改变了显示...我不敢相信我们可以在 SO 中回答这些奇怪的问题:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.