I am working on a web project and need to design an HTML page. I want to set the element's height to a percentage to make it better fit the page.
When I use float in CSS and set:
body, html{
height: 100%;
width: 100%
}
It doesn't work with height. I temporarily fixed it by changing the position
rather than using float. I want to to why it doesn't work. And anyone can help me?
This is the faulty code:
html, body{
width: 100%;
height: 100%;
margin: 0;
}
#test1, #test2{
display:inline-block;
height: 100%;
width:30%;
}
#test1{
float:left;
background: #111111;
}
#test2{
float:right;
background: #009A61;
}
#test3{
display:inline-block;
height: 100%;
width:40%;
background: cornsilk;
}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="test.css" />
</head>
<body>
<div id="test1"></div>
<div id="test3"></div>
<div id="test2"></div>
</body>
</html>
Exclude the above codes, the result following: detail image
It shouldn't appear white section in the bottom.