Responsive divs issue - one div fixed, second responsive with fixed margin - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive divs issue - one div fixed, second responsive with fixed margin

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">
* {<!--from ww  w.j  ava 2s . co  m-->
   margin:0;
   padding:0;
}

#wrapper {
   width:831px;
   margin:0 auto;
   padding-left:6px;
   padding-right:6px;
   box-sizing:border-box;
}

#content {
   width:501px;
   background:blue;
   float:left;
   box-sizing:border-box;
}

#sidebar {
   float:right;
   width:301px;
   margin-left:21px;
   background:yellow;
}

@media screen and (max-width: 50px)  {
   #wrapper {
      width:100%;
   }
   
   #content {
      width:100%;
      float:left;
   }
   
   #sidebar {
      float:left;
      margin-left:0px;
      width:301px;
   }

}
</style> 
 </head> 
 <body> 
  <div id="wrapper"> 
   <div id="content"> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
   </div> 
   <div id="sidebar"> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials