Make bootstrap carousel responsive on height

后端 未结 7 1675
夕颜
夕颜 2021-02-05 14:51

I need to customize BS carousel, to make images size responsive corectly. I need the carousel to adapt to the height of the active slides images initiel height. When the viewpor

7条回答
  •  你的背包
    2021-02-05 15:28

    To use images on Bootstrap carousel of different sizes and to do the followings, all at the same time,

    1. Image's width on carousael = 100%
    2. Carousel image slide height = fixed
    3. Maintain the image ratio

    Remove the img tag & add a new class instead, say slide1

    then add the following CSS code for slide1 class,

    .slide1{
        height: 500px;  /* your desired height for this slide */
        background: url(/img/your-img.jpg) no-repeat center center;
        background-size: cover;
    }
    

    You may also configure this heights for different window sizes.

提交回复
热议问题