Reputation: 91
why is that my div only color based on its content?which is the height of the button from the code below.the div is only wrapping its content.
my div element is
<div id="test">
<button>testing</button?
</div>
and in css
#test{
background-color:#666;
width:100%;
height:100%;
}
i set the height to 100% but it only colors the height of the element which is button.how can i color the whole height of the site?what would be the best way for it?
Upvotes: 1
Views: 5977
Reputation: 56509
Yes because the height of the div is occupied by the button.
so always start with below css to cover the browser
body, html {
width: 100%;
height: 100%;
}
Upvotes: 0
Reputation: 1836
If you have to color the whole site you can apply the css directly to body or html tag.
body, html {
min-height: 100%;
background-color:#666;
}
Upvotes: 0