Stretch horizontal ul to fit width of div

前端 未结 4 1892
梦毁少年i
梦毁少年i 2020-12-01 01:51

For the main nav of my site, there is a 980px wide div with a ul for the main nav links. I am trying to make the nav links stretch to fit the width of the div evenly.

4条回答
  •  -上瘾入骨i
    2020-12-01 02:43

    inelegant (but effective) way: use percentages

    #horizontal-style {
        width: 100%;
    }
    
    li {
        width: 20%;
    }
    

    This only works with the 5

  • example. For more or less, modify your percentage accordingly. If you have other
  • s on your page, you can always assign these particular ones a class of "menu-li" so that only they are affected.

提交回复
热议问题