javascript - CSS/Jscript height problems -
i trying make grid of squares updates size of window. using following js code this:
$(window).ready(updateheight); $(window).resize(updateheight); function updateheight() { var div = $('.grid'); var width = div.width();; div.css('height', width); var ratio=14.3/126; div = $('.face'); width = div.width();; div.css('height', width+(ratio*width)); ratio=30.5/15; div = $('.cubie'); width = div.width();; div.css('height', width+(ratio*width)); };
the cubies nested inside faces, nested inside grid in html. first tried setting height with
div.css('height', width)
..but reason didn't make faces , cubies square. ratio thing helps correct on screen size, smaller make window more noticeable error becomes, i'm searching different solution right now, , cant seem find one. appreciated.
ps: if matters, .grid width 50% of body, .face 20% of .grid, , .cubie ~33% of that.
Comments
Post a Comment