Set height of an element on multiples of a number?

前端 未结 3 1865
清酒与你
清酒与你 2021-01-16 03:13

Is there any way via jquery or javascript to make an element stretch its height to a certain set of numbers? I mean, as it accommodates more content, its height would only f

3条回答
  •  遥遥无期
    2021-01-16 03:32

    something like:

    $('element').css({ height : (0|(targetHeight + 99) / 100) * 100 });
    

    if you want it automatic:

    $(function(){
        var $elem = $('#element')
        $elem.css({ height : (0|($(elem).height() + 99) / 100) * 100 });
    });
    

提交回复
热议问题