Responsive image align center bootstrap 3

前端 未结 18 1171
半阙折子戏
半阙折子戏 2020-11-29 14:16

I do a catalog using Bootstrap 3. When displayed on tablets, the product images look ugly because of their small size (500x500) and a width of 767 pixels in the browser. I w

18条回答
  •  我在风中等你
    2020-11-29 15:14

    If you're using Bootstrap v3.0.1 or greater, you should use this solution instead. It doesn't override Bootstrap's styles with custom CSS, but instead uses a Bootstrap feature.

    My original answer is shown below for posterity


    This is a pleasantly easy fix. Because .img-responsive from Bootstrap already sets display: block, you can use margin: 0 auto to center the image:

    .product .img-responsive {
        margin: 0 auto;
    }
    

提交回复
热议问题