javascript - Height equal to dynamic width (CSS fluid layout) -
this question has answer here:
- maintain aspect ratio of div css 16 answers
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'});
Comments
Post a Comment