Fix size tag "li" and for bold font size decrease
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:
- The source should not decrease when ally is in bold.
In the event
a:hovercan not change the size of the tagli. - The tag
limust have fixed size, and not size depending on content. How can I fix the size o开发者_如何学运维f theli?
I don't know if I understood your question correctly, but can't you put
ul#menu li
{
width:200px; //change this amount...
}
You can prevent the boxes from jumping by
- floating the
lis - adding a
widthto thelis - adding left and right
paddingto thelis - taking the
hoveroff theaand adding it to thelis
--
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:
- the bolder text still jumps, but the boxes do not
- you will only be able to click on the text ** however you can make the entire
liclickable with js, if you like.
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:
- Remove padding from
liandaelements (it should be 0) - Set the
aelement todisplay:blockwith fixed width and height - Set
letter-spacingofaanda:hoverto 1px so they keep the same space between characters - Keep the text in the center with
line-heightandtext-align:center
The problem was that padding was pushing the box borders when the element changed its size.
加载中,请稍侯......
精彩评论