I'm attempting to create two separate divs, one covering the left half of the screen and one covering the right. Why does my code create only one div covering the left half of the page when I have included float:left
and float:right
? And how can I solve it?
#col-1 {
position: fixed;
width: 50%;
float: left;
height: 100%;
background-color: #282828;
z-index: 1010101010
}
#col-2 {
position: fixed;
width: 50%;
float: right;
height: 100%;
background-color: #0080ff;
z-index: 1010101010
}
<div id="col-1">
<h1>This is half of a page</h1>
</div>
<div id="col-2">
<h1>This is another half of a page</h1>
</div>