CSS: anchor will NOT accept height

前端 未结 3 1498
礼貌的吻别
礼貌的吻别 2020-12-20 15:15

I have been pulling my hair our for over an hour on this and I just can\'t understand why it\'s not working.

HTML:

&l
相关标签:
3条回答
  • 2020-12-20 15:49

    Try line height instead of height:

    line-height:36px

    http://jsfiddle.net/AlienWebguy/dP4F9/

    0 讨论(0)
  • 2020-12-20 15:52

    Change div#mainmenu div.menu ul li a to this:

    div#mainmenu div.menu ul li a
    {
        display: block;
        width: auto;
        background: none;
        margin: 10px auto;
    }
    

    a elements are inline by default and you cannot set the height / width of inline elements.

    0 讨论(0)
  • 2020-12-20 15:52

    The default display type for a link is inline, which does not respond to height or width. Instead, tell your links to be inline-blocks, which preserves the flow of the links but makes them respect your request to be a specific size (height).

    div#mainmenu div.menu ul li a
    {
        display:inline-block;
        height:36px;
    }
    
    0 讨论(0)
提交回复
热议问题