how to do a Responsive images in a list with inline-block

1.2k views Asked by At

so my problem is that i have 3 images with uneven width and still make them intact until it hit a certain width let's say 767px. and when it hit that width each of the images will take a full width of 767px until xs size of screen. sorry if this sentence construction make you crazy.

here's a piece

<div class= "about-content">

                    <ul>

                        <li><a href="">
                            <div class = "inner-content">

                                <img src="img/about/1.jpg" class="img-fluid">
                            </div>


                                </a></li><li><a href="">
                                <div class = "inner-content">
                                    <img src="img/about/2.jpg" class="img-fluid">
                                        <div class = "overlay-content">
                                            <h4>Book a Test Drive <i class = "fa fa-chevron-circle-right"></i></h4>                                 
                                        </div>
                                </div>


                                </a></li><li><a href=""><img src="img/about/3.jpg" class="img-fluid"></a></li>

                    </ul>
                    <ul>

                                <li><a href=""><img src="img/about/4.jpg">

                                </a></li><li><a href=""><img src="img/about/5.jpg">

                                </a></li><li><a href=""><img src="img/about/6.jpg"></a></li>

                    </ul>

                </div>
2

There are 2 answers

2
Julio Feferman On BEST ANSWER

The images will expand if you use vw (viewport width) measurement. Set a calculation to compensate for their starting positioning as in width: calc(100vw - 70px)

Here's a snippet:

img {
  width: 200px;
  height: 50px;
}

@media screen and (min-width: 767px) {
  img {
    width: calc(100vw - 70px);
  }
}
<div class="about-content">

  <ul>

    <li>
      <a href="">
        <div class="inner-content">

          <img src="img/about/1.jpg" class="img-fluid">
        </div>


      </a>
    </li>
    <li>
      <a href="">
        <div class="inner-content">
          <img src="img/about/2.jpg" class="img-fluid">
          <div class="overlay-content">
            <h4>Book a Test Drive <i class="fa fa-chevron-circle-right"></i></h4>
          </div>
        </div>


      </a>
    </li>
    <li>
      <a href=""><img src="img/about/3.jpg" class="img-fluid"></a>
    </li>

  </ul>
  <ul>

    <li>
      <a href=""><img src="img/about/4.jpg">

      </a>
    </li>
    <li>
      <a href=""><img src="img/about/5.jpg">

      </a>
    </li>
    <li>
      <a href=""><img src="img/about/6.jpg"></a>
    </li>

  </ul>

</div>

1
DreamRJ On

A way to globally give all images a responsive width is to just write this in your css file or inline style in the body tag:

<body style="img{width:100%;height:auto;}">

other way in the css file is:

img
{
width: 100%;
height: auto;
}

You can also change the % to lower as well just play around with the percent until u get it how you need it.

Ideally you should also read about @media queries