Layout 2 Divs side by side, for smaller screen, put one under another one - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:2 Column

Description

Layout 2 Divs side by side, for smaller screen, put one under another one

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">
#parent {<!--   w  w w .j  av a2  s.  co m-->
   width:100%;
   display:flex;
}

#section1 {
   width:51%;
   background-color:Chartreuse;
}

#section2 {
   width:51%;
   background-color:yellow;
}

@media (max-width: 400px)  {
   #parent {
      display:block;
   }

}
</style> 
 </head> 
 <body> 
  <div id="parent"> 
   <div id="section1">
     Section 1/ Section 1/ Section 1/ Section 1/Section 1/ Section 1/ Section 1/ Section 1 
   </div> 
   <div id="section2">
     Section 1/ Section 1/ Section 1/ Section 1/Section 1/ Section 1/ Section 1/ Section 1 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials