At this page, around viewport width 870px, there is a gap that appears underneath each .program-image img
:
How do I ensure each .program-image img
is the height of each .program
, or each .program
is the height of each .program-image img
?
Help appreciated.
<img>
tag isinline-block
element so you always need to definevertical-align
for it. else make it block.or use this
Maybe try:
or
on the image selector.
As the image height is dependant on its width, a gap is created because of this rule. To avoid this, I commonly add the image as a background image of a div, setting the background-size to cover (which makes the image cover the entire div).
First, remove the image tag and place the background image within the program-image div.
Then I would go ahead to add the following css:
This sets the height of the div as it will not take into account the height dimension of the image.
To make sure the image doesn't overflow over the program element. Add the following:
Below is an example of how it looks (Second program is of how it currently is, example excludes background-position:center apologies).
I hope this helps.