Reputation: 11059
I have this site, please note that in a:hover
put the source as bold.
The problem is that the font size decreases and eventually I read it also decreases.
There are two errors in the HTML you would like your help:
a:hover
can not change the size of the tag li
.li
must have fixed size, and not size depending on content. How can I fix the size of the li
?Upvotes: 0
Views: 3689
Reputation: 34855
You can prevent the boxes from jumping by
li
swidth
to the li
spadding
to the li
shover
off the a
and adding it to the li
s--
ul#menu li {
float:left;
width:120px;
background-color: #676767;
text-align:center;
padding:20px 20px;
margin:0 .25em;
}
ul#menu li a {
color: #FFFFFF;
text-decoration: none;
}
ul#menu li:hover {
font-weight: bold;
background-color: #868686;
color: #FFFFFF;
}
http://jsfiddle.net/jasongennaro/5jJg3/10/
Important:
li
clickable with js, if you like. Upvotes: 1
Reputation: 1026
I took the liberty to touch your css code to achieve the desired result. It would be:
ul#menu li
{
background-color: #676767;
display: inline-block;
text-align: center;
}
ul#menu li a
{
letter-spacing: 1px;
color: #FFFFFF;
display: block;
line-height: 45px;
padding: 0;
text-decoration: none;
width: 100px;
}
ul#menu li a:hover
{
letter-spacing: 1px;
font-weight: bold;
background-color: #868686;
color: #FFFFFF;
}
What I did was:
li
and a
elements (it should be 0)a
element to display:block
with fixed width and heightletter-spacing
of a
and a:hover
to 1px so they keep the same space between charactersline-height
and text-align:center
The problem was that padding was pushing the box borders when the element changed its size.
Upvotes: 1
Reputation: 3099
I don't know if I understood your question correctly, but can't you put
ul#menu li
{
width:200px; //change this amount...
}
Upvotes: 2