Auto height div with overflow and scroll when needed

后端 未结 10 2332
醉梦人生
醉梦人生 2020-12-08 06:45

I\'m trying to make a website with no vertical scrolling for a page, but i need that one of the DIVs i have to expand vertically to the bottom of the page (at most), and tha

10条回答
  •  粉色の甜心
    2020-12-08 06:54

    $(document).ready(function() {
    //Fix dropdown-menu box size upto 2 items but above 2 items scroll the menu box
        $("#dropdown").click(function() {
            var maxHeight = 301;
            if ($(".dropdown-menu").height() > maxHeight) { 
                maxHeight = 302;
                $(".dropdown-menu").height(maxHeight);
                $(".dropdown-menu").css({'overflow-y':'scroll'});
            } else {
                $(".dropdown-menu").height();
                $(".dropdown-menu").css({'overflow-y':'hidden'});
            }
        });
    });

提交回复
热议问题