Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Menu items moving when one goes bold on hover

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #45461
    jtwalter
    Participant

    I am currently experiencing something weird with the menu items on this page:

    http://www.garrettbenson.com/index2.php

    The borders are just to see the spacing more easily. I set them to go bold on hover, but the problem is all the others move when one is rolled over. This makes sense since they are all relative to one another. It is most notable in Safari. Does anybody have a suggestion as to how I could get around this with a different way of spacing them? Tables? Percentages? A property I’m missing?

    Thank you for any info!

    Julian

    #138408
    Alen
    Participant

    Line #28 in your CSS `#menu a:hover {padding: 1px;}` you are adding padding which then exceeds the width of container.

    Consider adding, top of your stylesheet:
    `*{
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    box-sizing:border-box;
    }`

    More here: http://learnlayout.com/box-sizing.html

    #138409
    jtwalter
    Participant

    Thank you AlenAbdula for the response. The 1px padding on hover was to minimize the effect of the font change in Firefox as I was looking at it, but then on Safari it was still very prominent. This is what made me realize it might not be the best way to do it. My mind is totally blanking on other ways this could be done!

    I got no change with the box-sizing property.

    #138426
    akshan
    Participant

    Just try to give the **Width** and **float:left** to individual span according to text.

    #138428
    CodeGraphics
    Participant

    Remove the font-weight:bold in your hover. It will continue to choke as long as the anchor link doesnt have bold effect. Check [here.](http://codepen.io/codegraphics/pen/gzipG “”)

    #138461
    Paulie_D
    Member
    #138478
    wolfcry911
    Participant

    there will be no difference Paulie – the widths are still determined by font size and weight.
    Like CodeGraphics states, one way to have this is work is to _not_ use bold on hover. Another would be to use fixed widths. Here’s an example using text-shadow to increase contrast:

    http://www.codepen.io/wolfcry911/pen/nsojI

    #138563
    rawat3209
    Participant

    you have to give different padding to both a and hover (bold) property. This is the perfect fix of this solution.

    #138564
    Paulie_D
    Member

    >This is the perfect fix of this solution.

    Well…it’s **a** fix at least.

    #138607
    wolfcry911
    Participant

    It’s definitely not a _perfect_ fix. The fonts render differently on different browsers and platforms – you will never be able to adjust padding to compensate.

    #138878
    jtwalter
    Participant

    Thanks so much for all the replies! This forum is really awesome.

    I will probably go with a fixed width on the spans because my friend really likes the bold effect. I figured there had to be some weird way to get it to not affect the width but I might be wrong. @rawat3209 I had this set before but only noticed the real problem when I opened different browsers and the bold effect is way different on each. I could potentially target each browser but it’s a bit of a pain.

    Thanks again!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘CSS’ is closed to new topics and replies.