Html 身体背景颜色不显示?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26813335/
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
body background color not showing?
提问by ByteDuck
I just have a simple .shtml page:
我只有一个简单的 .shtml 页面:
<html>
<head>
<meta charset='utf-8'>
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link href="Stylesheets/main.css" rel="stylesheet">
<link href="Stylesheets/glicons.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<title>
Codepixl
</title>
</head>
<body>
<!--#include file="nav.html"-->
asdsd
<div id="Scripts">
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="Scripts/jquery.cookie.js"></script> <script src="Scripts/jquery-ui.min.js"></script> <script src="scripts/typed.js"></script> <script src="//codepixl.net/scripts/secret.js"></script>
</div>
</body>
</html>
and the stylesheet:
和样式表:
body{
background-color: #32CD32;
}
.loader {
position: fixed;
top: 50%;
left: 50%;
margin-top: -115px;
margin-left: -115px;
z-index: 9999;
}
But the background color isn't showing up? I've tried using html,body{} and using a doctype but nothing works! What's happening?
但是背景颜色没有显示出来?我试过使用 html,body{} 并使用 doctype 但没有任何效果!发生了什么?
EDIT:I removed bootstrap and it started working... Also here's the page: http://codepixl.net/indesx.shtml
编辑:我删除了引导程序,它开始工作......也是这个页面:http: //codepixl.net/indesx.shtml
EDIT:I just had to put the bootstrap before my stylesheet -_-
编辑:我只需要将引导程序放在我的样式表之前-_-
采纳答案by lukevp
Comment your Bootstrap include and see if the body is applied. You should try to test with the minimal amount of code first and then add in things.
评论您的 Bootstrap 包含并查看是否应用了正文。您应该先尝试使用最少的代码进行测试,然后再添加一些东西。
If that doesn't work, you can use an inspector in Firefox or Chrome to see what CSS effects are applied.
如果这不起作用,您可以使用 Firefox 或 Chrome 中的检查器来查看应用了哪些 CSS 效果。
You also may want to use the network inspector in Chrome to determine if your stylesheet is actually even getting downloaded or if the link is incorrect.
您可能还想使用 Chrome 中的网络检查器来确定您的样式表是否真的被下载或者链接是否不正确。
回答by Stella Hu
Override style from Bootstrap by adding `!important``
通过添加 `!important` 覆盖 Bootstrap 的样式
body{
background-color: #32CD32 !important;
}
回答by almost a beginner
html {
height: 100%;
}
body {
background-color:#cccccc;
}
This worked for me. Without setting the height in html, the background-color property of body wouldn't work at all.
这对我有用。如果没有在 html 中设置高度,则 body 的 background-color 属性根本不起作用。
回答by UserDy
Its possible that your body has a height of 0px. Add height:100%
to your body styles and see if that works.
你的身体有可能是 0px 的高度。添加height:100%
到您的身体风格,看看是否有效。