Swap DIV position with CSS only - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Swap DIV position with CSS only

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>Lorem ipsum dolor sit amet, con</title> 
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> 
  <style>
.container {<!--from w w w  . j a  v  a  2 s  . com-->
   display:table;
}

.div1 {
   display:table-footer-group;
}

.div2 {
   display:table-row-group;
}

.div3 {
   display:table-header-group;
}

body {
   background:Chartreuse;
   color:yellow;
   font-size:21px;
}

.container {
   width:91%;
   margin:100px auto;
   max-width:501px;
   border:11px solid blue;
   text-align:center;
}

.container div span {
   padding:21px;
   display:block;
   border:6px solid pink;
   background:OrangeRed;
}
</style> 
 </head> 
 <body translate="no"> 
  <div class="container"> 
   <div class="div1"> 
    <span>L</span> 
   </div> 
   <div class="div2"> 
    <span>L</span> 
   </div> 
   <div class="div3"> 
    <span>L</span> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials