Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Why the img is coming 1px down on hover? Re: Why the img is coming 1px down on hover?

#122821
wolfcry911
Participant

Images are inline by default. Space is therefore reserved ‘under’ the image for the descenders of a font – it rests on the baseline. There are a number of ways to get the effect you want, two of which have been mentioned: with a line-height of 0 the baseline is at the bottom of the inline-box; changing the default display value to block removes the inline characteristics the image would normally have. The third way is to set the image to the bottom of the inline-box with vertical-align: bottom;