Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

make unordered image list spacing smaller

I am trying to make the spacing between the images less. I have tried grid gap, but its not seeming to make any difference. I just want to be able to control this area.

 #Listed{
    display: grid;
    grid-gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
  }
  .Img{
        width: 60px;
        height: 60px;
      }
  <div id="Listed">
                <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/1">
    
                </div>
                <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/2"><br>

                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/3"><br>

                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/4"><br>

                </div>
                <div class="style">
    <img class="Img" src="https://source.unsplash.com/random/34"><br>
                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/6"><br>

                </div>
              </div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is caused by using auto-fill which will cause the elements to fill the entire width. Try using auto-fit with a 60px value in the minmax like…

#Listed{
    display: grid;
    grid-gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
  .Img{
        width: 60px;
        height: 60px;
      }
<div id="Listed">
                <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/1">
    
                </div>
                <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/2"><br>

                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/3"><br>

                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/4"><br>

                </div>
                <div class="style">
    <img class="Img" src="https://source.unsplash.com/random/34"><br>
                </div>
                  <div class="style">
                  <img class="Img" src="https://source.unsplash.com/random/6"><br>

                </div>
              </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading