Reputation: 21729
My link: <a href="#">Home page</a>
Css:
a:hover
{
padding: 5px;
background: black;
}
When I hover over home page link, it moves, because I use padding. How can I avoid it? I want that black background would appear where the link is without moving its link and other links. Thanks.
Upvotes: 4
Views: 11854
Reputation: 3060
You can add it by default:
a { padding: 5px; }
Or you can use margins:
a { margin: 5px; }
a:hover { margin: 0px; padding: 5px; }
This should work:
a {
padding: 5px;
}
a:hover {
background: black;
}
Upvotes: 4
Reputation: 17472
remove the padding on hover, if you want padding use which will be there all the times.
a{
padding: 5px;
}
Did I answer your question?
Upvotes: 1