CSS: Fixed with horizontal menu, with variable width tabs, using ul

前端 未结 5 532
春和景丽
春和景丽 2020-12-15 09:40

I have a horizontal menu. The markup looks like this:

  • Item 1
  • Longer Item 2
5条回答
  •  臣服心动
    2020-12-15 10:36

    This is a case for

    Display:Table-Man

    ul {
      display: table;
      width: 100%;
      table-layout: fixed;
    }
    li {
      display: table-cell;
    }
    

    Unfortunately, you should abandon the thought of supporting IEs 6 and 7, but else this is the way to go (or switching to HTML tables, which might or might not be so far away from the semantic content of the markup).

提交回复
热议问题