html - Float left and clear both are not working properly -


i'm trying put 1 div below one, code not working properly. can see in code below, there wrapper ("#main"), top ("#top"), floating left, , content ("#content"), floating left , clearing left also. here code:

<html>     <head>         <meta charset="utf-8">         <link rel="stylesheet" type="text/css" href="style.css">         <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>         <script type="text/javascript" src="js/script.js"></script>         <title></title>     </head>     <body>         <div id="main">             <div id="top">              </div>             <div id="content">              </div>             <div id="footer">              </div>         </div>     </body> </html> 

css:

#top{     width: 100%;     height: 100%; <!-- tried putting fixed height -->     left: 0px;     top: 0px;     position: absolute;     background-color: #ff0000;     display: block;     float: left; }  #content{     width: 600px;     height: 400px;     left: 50%;     transform: translatex(-50%);     background-color: #999999;     position: absolute; <!-- tried removing line -->     display: block; <!-- tried removing line , same 1 #top-->     float: left; <!-- tried removing line -->     clear: left; <!-- tried clear:both --> } 

but, reason, grey div not going under red one. have no idea happening. please find below image showing on browser.

enter image description here

as top positioned absoulte cant clear left,

try reomving property form #top

 position:absolute; 

and #content remove

 position:absolute;  transform: translatex(-50%);  float:left; 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -