Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS hover border makes inline elements adjust slightly

Tags:

css

I have an unordered list full or anchors. I have a CSS :Hover event that adds borders to it but all the anchors to the left slightly adjust when i hover because it is adding 1px to the width and auto adjusting. how do i make sure the positioning is absolute?

I made a JS Fiddle here.

like image 876
user1082764 Avatar asked Dec 24 '11 17:12

user1082764


People also ask

How do I apply a border to the element on a mouse hover without affecting the layout in CSS?

Answer: Use the negative CSS margin.

Can we use hover in inline CSS?

Short answer: you can't. Long answer: you shouldn't. Give it a class name or an id and use stylesheets to apply the style. :hover is a pseudo-selector and, for CSS, only has meaning within the style sheet.

How do you use hover inline style?

It is called pseudo-selector and used to select all the elements when the user move mouse over the elements. It can be used on all the element. A <!


1 Answers

You can add a transparent border to the non-hover state to avoid the "jumpiness" when the border appears:

http://jsfiddle.net/TEUhM/3/

#homeheader a:visited, #homeheader a{     border:1px solid transparent; } 
like image 185
Wesley Murch Avatar answered Oct 21 '22 04:10

Wesley Murch