set all nested li's to be width of widest li

后端 未结 6 1632
情书的邮戳
情书的邮戳 2021-01-13 21:30

How do I make nested li\'s the same width?

When I use the below code each nested li is only as wide as it\'s text + margin.

I\'d like all of the li\'s to be

6条回答
  •  广开言路
    2021-01-13 21:47

    There would be a very simple dynamic solution. To your CSS, as you posted it in the Question, just add

    #menu ul {
        display: inline-block;
        min-width: 100px;
    }
    
    #menu ul li, #menu ul li a{
        width: 100%;
        display:block;
    }
    

    and then it will be exactly as you want it to be.

    You can see how it looks here: