Change order and positioning using only css - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Change order and positioning using only css

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">
#box1 {<!--from w  ww. j ava2 s.  c o m-->
   width:151px;
   height:51px;
   background-color:Chartreuse;
   margin:11px auto 11px auto;
}

#box2 {
   width:201px;
   height:100px;
   background-color:yellow;
   margin:11px auto 11px auto;
}

@media (min-width: 450px)  {
   #outer {
      float:left;
   }
   
   #box1, #box2 {
      margin:11px;
      float:right;
   }
   
   #box1 {
      margin-top:36px;
   }

}
</style> 
 </head> 
 <body> 
  <div id="outer"> 
   <div id="box1"></div> 
   <div id="box2"></div> 
  </div>  
 </body>
</html>

Related Tutorials