Make bootstrap carousel responsive on height

后端 未结 7 1659
夕颜
夕颜 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:26

    I was having the same problem as above. Here's my solution. I changed a few lines of CSS:

    .carousel {
      margin-bottom: 60px;
    }
    
    /* Since positioning the image, we need to help out the caption */
    .carousel-caption {
      z-index: 10;
    }
    
    /* Declare heights because of positioning of img element */
    .carousel .item {
      min-width: 100%;
      background-color: #fff;
    }
    
    .carousel-inner > .item > img {
      min-width: 100%;
      height: 100%;
    }
    

    I hope this helps.

提交回复
热议问题