Responsive images inline-block in a div with Bootstrap

前端 未结 2 1506
悲&欢浪女
悲&欢浪女 2021-01-04 04:31

I am new in Bootstrap, I am trying to do this responsive: A div, with 3 images centered (images have display: inline-block propertie).

But when I start resizing, in

相关标签:
2条回答
  • 2021-01-04 05:09

    I would rather go for width:100% instead of class="img-responsive"

    0 讨论(0)
  • 2021-01-04 05:17

    In the case of responsive images, the image(s) need an individual container that they can be sized into. In the example you have, there are three images in the one container, so they won't adapt individually to that single container. You could try something like:

    .row li {
      width: 33.3%;
      float: left;
    }
    
    img {
      border: 0 none;
      display: inline-block;
      height: auto;
      max-width: 100%;
      vertical-align: middle;
    }
    <div class="row">
      <div id="small-img" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 center">
        <ul>
          <li>
            <img src="http://placehold.it/150x100" class="img-responsive inline-block" alt="Responsive image" />
          </li>
          <li>
            <img src="http://placehold.it/150x100" class="img-responsive inline-block" alt="Responsive image" />
          </li>
          <li>
            <img src="http://placehold.it/150x100" class="img-responsive inline-block" alt="Responsive image" />
          </li>
        </ul>
      </div>
    </div>

    0 讨论(0)
提交回复
热议问题