How to display inline several
  • with 100% width?
  • 后端 未结 7 1387
    灰色年华
    灰色年华 2020-12-21 01:24

    I have the following html:

    • element 1
    • element 2
    <
    7条回答
    •  半阙折子戏
      2020-12-21 01:53

      You want it to act like a good old fashioned table:

      
      
      
      .menu {
          display: table;
          width: 100%;
      }
      .menu li {
          display: table-cell;
          padding: 2px;
      
          background: #900990;
          border: 1px solid yellow;
          color: white;
      }
      

      then you can also collapse it nicely when the page is small:

      /* responsive smaller screen turn into a vertical stacked menu */
      @media (max-width: 480px) {
      
         .menu, .menu li {
             display: normal;
          }
      
      }
      

    提交回复
    热议问题