I'm learning to build a responsive website for myself. I'm having a problem with the box-sizing border-box on the top and bottom borders of one of my images. I have two columns of images of different heights, I want the edges to match up but I also want a few pixels of white space to separate each image.
My problem is when using box-sizing border-box on the top and bottom borders they stay outside of the edge of the image thus pushing the next image below down by a few pixels making it no longer match it's neighbour on the bottom edge.
I want to fix this issue before going ahead and adding borders on the other images. I'm new to CSS so perhaps there is something very obvious i've got wrong?
Any help to get the borders to stay on the inside edge of the images would be greatly appreciated!
I've attached a screen grab of what is happening. border-box problem
#rightCol {
width: 50%;
height: auto;
float: right;
box-sizing: border-box;
border-left: 2px solid white;
}
#rightCol img {
width: 100%;
height: 100%;
display: block;
}
#leftCol {
width: 50%;
height: auto;
-moz-box-sizing: border-box;
box-sizing: border-box;
border-right: 2px solid white;
}
#leftCol img {
width: 100%;
height: 100%;
display: block;
}
.innerBorder {
-moz-box-sizing: border-box;
box-sizing: border-box;
border-top: 4px solid white;
border-bottom: 4px solid white;
}
<div id="rightCol">
<div>
<img src="./images/pa.jpg" />
</div>
<div>
<img src="./images/game.jpg" />
</div>
<div>
<img src="./images/spine.jpg" />
</div>
</div>
<div id="leftCol">
<div>
<img src="./images/truck.jpg" />
</div>
<div>
<img class="innerBorder" src="./images/ccc.jpg" />
</div>
<div>
<img src="./images/box.jpg" />
</div>
</div>