Responsive and perfect square div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive and perfect square div

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">
.field {<!--from w w w .  j av a2  s.  c om-->
   background:Chartreuse;
   border:2.26vh solid yellow;
}

.field .player {
   width:6vh;
   height:6vh;
   background:blue;
}

@media only screen and (orientation: portrait)  {
   .field {
      width:76vw;
      height:76vw;
   }

}

@media only screen and (orientation: landscape)  {
   .field {
      width:76vh;
      height:76vh;
   }

}
</style> 
 </head> 
 <body> 
  <div class="field"> 
   <div class="player"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials