Cwtch22
Cwtch22

Reputation: 79

DIV Background color not showing with body color

I have set the body background color to the color of Light Grey#D6D6D6and I wish to have a div displayeing with the background color of light blue #2390bbHowever, 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; Image

Upvotes: 2

Views: 2623

Answers (1)

dbermudez
dbermudez

Reputation: 572

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!

Upvotes: 6

Related Questions