height 50% of width

http://stackoverflow.com/questions/10062811/can-i-set-the-height-of-a-div-based-on-a-percentage-based-width

by Roberto Apasajja

HTML

<div id="dynamicheight">sdsd</div>

CSS

#dynamicheight {
    width: 50%;    
    background-color: cornflowerblue;
}

JavaScript

$(function() {
    var div = $('#dynamicheight');
    var width = div.width();
    
    div.css('height', width/2);
});