문제

I am computing elements width on page load with jq and works fine , trying to automate on window resize but kinda does not work. Desired effect: Boxes should auto resize on window resize and not drop down.

http://jsfiddle.net/yMcXm/4/

any help is appreciated . Thank you!

도움이 되었습니까?

해결책

Try $(window).resize See below,

$(document).ready(function() {
    var cw = $('#container').width();
    $(".box").width(cw / 5);

    $(window).resize(function() {
        var cw = $('#container').width();
        $(".box").width(cw / 5);
    });
});

Also used overflow property on the container and box_in, so that the elements/text inside are contained/hidden.. instead of going out.

DEMO: http://jsfiddle.net/skram/yMcXm/7/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top