HTML CSS examples for CSS Layout:Responsive Layout
Responsive height proportional to width
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .content {<!--from w w w. j a v a 2 s. c om--> width:100%; height:0; padding-bottom:31%; background-color:Chartreuse; } .wrapper { position:relative; width:100%; padding-bottom:31%; background-color:yellow; } .wrapper .content2 { position:absolute; width:100%; height:100%; background-color:blue; } </style> </head> <body> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed </div> <br> <div class="wrapper"> <div class="content2"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum </div> </div> </body> </html>