I have a CSS table and I would like to have space in-between the cells but not at the left of the first image and the right of the last image.
Here is a screenshot of what I have:
Here is a screenshot of what I would like:
The current HTML is:
<div id="footer">
<div class="lower"><img src="images/one.jpg" alt="Ring being put on finger"/></div>
<div class="lower"><img src="images/two.jpg" alt="The mens trousers"/></div>
<div class="lower"><img src="images/three.jpg" alt="Flowers"/></div>
<div class="lower"><img src="images/four.jpg" alt="The rings"/></div>
</div>
and the CSS is
#footer {
display: table;
width: 100%;
max-width: 1024px;
margin-top: 1%;
}
.lower {
display: table-cell;
}
#footer img {
width: 100%;
height: auto;
max-width: 256px;
}
Please bear in mind that this is a responsive webpage so I would like the space to always remain however I would like the space to change according to device size, so using %.
Try
display: flex;
instead ofdisplay: table;
Give
display: flex;
andjustify-content: space-between;
to the parent.Apply this.
Demo
Use CSS adjacent element selector: