Positioning a div below another - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Positioning a div below another

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!--from w ww. j  a  v  a 2s  . co m-->
   background-color:Chartreuse;
   color:yellow;
   font-family:Arial,Verdana,Helvetica,sans-serif;
   margin:0;
}

#bg {
   position:relative;
   width:100%;
}

#content {
   color:blue;
   margin-left:21px;
}

#nav {
   overflow:hidden;
   margin:0;
   padding:0;
   list-style:none;
   background-color:pink;
   border-bottom:2px solid OrangeRed;
   border-top:2px solid grey;
}

#nav li {
   float:left;
}

#nav li a {
   display:block;
   padding:9px 16px;
   text-decoration:none;
   font-weight:bold;
   color:BlueViolet;
   border-right:2px solid Chartreuse;
}

#nav li a:hover {
   color:yellow;
   background-color:blue;
}

#nav ab {
   float:right;
}

#nav ab a {
   display:block;
   padding:9px 16px;
   text-decoration:none;
   font-weight:bold;
   color:pink;
   border-right:2px solid OrangeRed;
}

#nav ab a:hover {
   color:grey;
   background-color:BlueViolet;
}

#quote {
   position:absolute;
   color:Chartreuse;
   top:21px;
   width:351px;
   margin-left:21px;
}
</style> 
 </head> 
 <body> 
  <title>Lorem ipsum dolor sit</title> 
  <meta charset="iso-8859-1&quot;"> 
  <link href="style.css" rel="stylesheet" type="text/css"> 
  <ul id="nav"> 
   <li> <a href="http://tri-peoria.org">Lore</a> </li> 
   <li> <a href="/forum">Lorem</a> </li> 
   <li> <a href="/join">Lore</a> </li> 
   <li> <a href="/members">Lorem i</a> </li> 
   <li> <a href="/events">Lorem </a> </li> 
   <li> <a href="/training">Lorem ip</a> </li> 
   <li> <a href="https://www.facebook.com/groups/tripeoria/">Lorem ip</a> </li> 
   <ab> 
    <a href="/about">Lorem ipsum dolor sit</a> 
   </ab> 
  </ul> 
  <div id="bg"> 
   <p id="quote">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie la</p> 
   <img src="https://www.java2s.com/style/demo/Google-Chrome.png" width="100%" alt=""> 
   <p id="content">Lorem i</p> 
  </div>  
 </body>
</html>

Related Tutorials