Stretch and fill image in Bootstrap carousel

前端 未结 14 1319
情歌与酒
情歌与酒 2021-01-11 13:11

I am using bootstrap carousal and having some problem with image height and width. Even though I define it in the img attribute it still displays a

14条回答
  •  终归单人心
    2021-01-11 14:01

    You can do that with the following styles:

    .carousel-inner .item{
      width: 600px; /* Any width you want */
      height: 500px; /* Any width you want */
    }
    .carousel-inner .item img{
      min-width: 100%;
      min-height: 100%;
    }
    

    By setting min-* to the image attributes, we're making sure we have at least 100% of both width and height.

    Updated JSFiddle

提交回复
热议问题