Bootstrap change carousel height

前端 未结 5 1593
北荒
北荒 2020-12-10 11:05

I have a jsfiddle here - http://jsfiddle.net/gh4Lur4b/8/

It\'s a full width bootstrap carousel.

I\'d like to change the height and still keep it full width.<

5条回答
  •  一整个雨季
    2020-12-10 11:40

    Thank you! This post is Very Helpful. You may also want to add

    object-fit:cover;

    To preserve the aspect ration for different window sizes

    .carousel .item {
      height: 500px;
    }
    
    .item img {
        position: absolute;
        object-fit:cover;
        top: 0;
        left: 0;
        min-height: 500px;
    }
    

    For bootstrap 4 and above replace .item with .carousel-item

    .carousel .carousel-item {
      height: 500px;
    }
    
    .carousel-item img {
        position: absolute;
        object-fit:cover;
        top: 0;
        left: 0;
        min-height: 500px;
    }
    

提交回复
热议问题