There seems to be some excess space on the right side of my gallery...
The container for my images:
.my-gallery figure {
display: block;
float: left;
width: 150px;
}
Is it possible to always horizontally center images on different screen sizes without using a percentage value? Any brilliant ideas to make the excess space less noticeable?
Or is using a percentage value the only solution?
In screen A:
https://i.sstatic.net/L4hiZ.jpg
In screen B:
https://i.sstatic.net/1XoCi.png
.my-gallery {
width: 100%;
float: left;
}
.my-gallery img {
width: 100%;
height: 112px;
}
.my-gallery figure {
display: block;
float: left;
margin: 0 5px 5px 0;
width: 150px;
}
.my-gallery figcaption {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
min-height: 26px;
}
.my-gallery img {
max-width: 100%;
}
<div class="my-gallery">
<figure>
<a href="big1.jpg">
<img src="http://placehold.it/112x150" alt="1" />
</a>
<figcaption>111111111111111111111111</figcaption>
</figure>
<figure>
<a href="big2.jpg">
<img src="http://placehold.it/112x150" alt="2" />
</a>
<figcaption>222222222222222222222222</figcaption>
</figure>
<figure>
<a href="big3.jpg">
<img src="http://placehold.it/112x150" alt="3" />
</a>
<figcaption>3333333333333333333333333333333</figcaption>
</figure>
<figure>
<a href="big4.jpg">
<img src="http://placehold.it/112x150" alt="4" />
</a>
<figcaption>444444444444444444444444</figcaption>
</figure>
...
</div>