I can not find a good solution to this problem. I have 2 divs inside the parent div. When I try and float divs left and right to make 2 columns inside the parent div, the child divs fall under the parent div.
<head> <link rel="stylesheet" type="text/css" href="float.css" /> </head> <body class="wrapper"> <div class= "whole"> <div class="left"> <p> Hello </p> </div> <div class="right"> <p> Hello Again</p> </div> </div> </body>
CSS
.whole { padding: 30px 30px 15px 30px; background-color: yellow; margin-bottom: 30px; } .left { width:50%; position:relative; float: left; background-color:green; } .right { width:50%; position:relative; float: right; background-color:red; }
Why is the content in the child divs "right, left" below the parent div "whole"?
Peter source share