Responsive height proportional to width

后端 未结 3 1788
借酒劲吻你
借酒劲吻你 2020-12-29 04:33

Is it possible to implement the following logic usic HTML and CSS?

width: 100%;
height: 30% of width;

What I want to implement: If I decrea

3条回答
  •  轮回少年
    2020-12-29 04:55

    Also with JQuery, you could do:

    $(window).ready(function () {
        var ratio = 3 / 10, $div = $('#my_proportional_div');
        $div.height($div.width() * ratio);
        $(window).bind('resize', function() { $div.height($div.width() * ratio); });
    });
    

    because the Padding % solution suggested doesn't work with max/min-width and max-min height.

提交回复
热议问题