How to make images in Bootstrap Carousel responsive?

前端 未结 3 1222
猫巷女王i
猫巷女王i 2020-12-18 04:34

Is there a way to make your images within bootstrap\'s carousel responsive with a fixed height? I\'ve tried everything. I also used img-responsive, and in the CSS I tried

3条回答
  •  一向
    一向 (楼主)
    2020-12-18 05:18

    Try this jq, it makes your .carousel-inner as window height. but remember to -height your navnbar, footer ect. all other elements/divs heights you have to -.

    function init_carousel() {
                H = +($(window).height() /* -height here  */); // or $('.carousel-inner') as you want ...
                $('.carousel-inner').css('height', H + 'px');
            }
            window.onload = init_carousel;
            init_carousel();
    

提交回复
热议问题