Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can we avoid the shake when we hover over an element and set its font to be bold

Tags:

html

css

shake

How can we avoid the shake when we hover over an element and set its font to show bold? Here is a sample of the code I wrote:

http://jsfiddle.net/8v4Ag/

Is there a technique to avoid the shaking? Suppose I hover on LogOff, the font goes bold, but that line of text moves a little to the right due to the text getting emboldened. If we hover away it again shakes.

Is there any CSS way of avoiding such shakes?

like image 390
deostroll Avatar asked Jan 25 '26 13:01

deostroll


1 Answers

I have solved this by having a non visible duplicate text with the hover style. Use visibility:hidden rather than display:none to make it take up space, and position it beneath the original text. This invisible element will make sure the text is wide enough for the hover state.

Her is an example

like image 128
rlovtang Avatar answered Jan 27 '26 02:01

rlovtang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!