DIV背景颜色不与身体颜色一起显示 [英] DIV Background color not showing with body color
问题描述
我已将背景颜色设置为浅灰色#D6D6D6
的颜色,我希望div背景颜色为浅蓝色#2390bb
然而,这只是不起作用,div不显示淡蓝色。任何想法为什么?非常感谢,以下是代码;
HTML;
<< ;!DOCTYPE html>
< html>
< head>
< link rel =stylesheettype =text / csshref =css / style.css>
< style>
body {
background-color:#D6D6D6;
}
< / style>
< / head>
< body>
<! - TOP COLOR BG - >
< div id =bg-top>< / div>
< / body>
< / html>
CSS;
#bg-top {
background-color:#2390bb;
}
下面是我想表达的内容;
接着我的评论:
你的问题是div没有内容...没有宽度/高度...所以蓝色不是显示。
在css中使用它来避免边缘上的空白:
#bg-top {
background-color:#2390bb;
位置:绝对;
top:0;
剩下:0;
宽度:100%;
height:200px;
如果这有助于您,Plz会将答案标记为解决方案!
I have set the body background color to the color of Light Grey#D6D6D6
and I wish to have a div displayeing with the background color of light blue #2390bb
However, this just doesn't work, the div does not show the light blue color. Any ideas why? Thanks a lot, here's the code;
HTML;
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style>
body {
background-color: #D6D6D6;
}
</style>
</head>
<body>
<!--TOP COLOR BG-->
<div id="bg-top"></div>
</body>
</html>
CSS;
#bg-top {
background-color: #2390bb;
}
Here's a representation of what I would like;
Following my comment:
Your problem is the div has no content... no width/height... and so the blue color is not displayed.
Use this in the css to avoid the gaps on the edges:
#bg-top {
background-color: #2390bb;
position:absolute;
top:0;
left:0;
width: 100%;
height: 200px;
}
Plz mark the answer as solution if this has helped you!
这篇关于DIV背景颜色不与身体颜色一起显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!