[英]Why doesn't the CSS apply to div?
I want to add a footer and started by creating a div in my html like this: 我想添加一个页脚,并首先在html中创建一个div,如下所示:
<div class="footer"></div>
and the CSS: 和CSS:
.footer {
width: 100%;
height: 80px;
background-color: #ec6608;
}
but for some reason, all browsers do not apply the css to the div. 但由于某些原因,所有浏览器均未将CSS应用于div。 So the div does not have any styles.
因此div没有任何样式。 I tried positioning the div somewhere else in the html, just to be sure this is not a weird placement problem.
我尝试将div放置在html中的其他位置,以确保这不是一个奇怪的放置问题。 Did the same in the css document.
在css文档中做了同样的事情。 I also used another name for the class and I tried using an id instead.
我也为该类使用了另一个名称,并尝试使用id代替。 Than I tried to create the footer without a div just by using the tag footer and styled it the same way: no problem there.
比起我,我尝试仅通过使用标签页脚创建不带div的页脚,并以相同的方式对其进行样式设置:在那里没有问题。 Why the div version won't work?
为什么div版本不起作用? How I can add my css and html files?
如何添加CSS和HTML文件?
I guess you didn't link the css file in the html page. 我想您没有在html页面中链接css文件。 This might help.
这可能会有所帮助。
<link rel="stylesheet" type="text/css" href="link_to_your_css_file" />
Do this in the head section of the html code. <link rel="stylesheet" type="text/css" href="link_to_your_css_file" />
在html代码的开头部分执行此操作。
If you've pre-defined CSS
rule for .footer
then try to overwrite it like this: 如果您已经为
.footer
预定义了CSS
规则, .footer
尝试像这样覆盖它:
.footer {
width: 100% !important;
height: 80px !important;
background-color: #ec6608 !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.