javascript - Height equal to dynamic width (CSS fluid layout) -


this question has answer here:

is possible set same height width (ratio 1:1)?

example

+----------+ | body     | | 1:3      | |          | | +------+ | | | div  | | | | 1:1  | | | +------+ | |          | |          | |          | |          | |          | +----------+ 

css

div {   width: 80%;   height: same-as-width } 

using jquery can achieve doing

var cw = $('.child').width(); $('.child').css({'height':cw+'px'}); 

check working example @ http://jsfiddle.net/n6dau/1/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -