Align 3 unequal blocks left, center and right

前端 未结 4 1118
春和景丽
春和景丽 2020-11-22 06:18

I\'m trying to align a top menu which consists of 3 blocks of content.

What I\'m trying to achieve is this:

  • block 1: left aligned
  • block 2: cen
4条回答
  •  孤城傲影
    2020-11-22 06:46

    Alternative using display table (an ancient supported grid).

    Quote from https://www.w3schools.com/cssref/pr_tab_table-layout.asp

    If no widths are present on the first row, the column widths are divided equally across the table, regardless of content inside the cells

    .container {
       display: table;
       table-layout: fixed
     } // would divide cells equally along table's 100% width. 
    .row {
       display: table-row
     }
    .item {
       display: table-cell
     }
    

提交回复
热议问题