Align two inline-blocks left and right on same line

后端 未结 9 792
滥情空心
滥情空心 2020-11-27 11:50

How can I align two inline-blocks so that one is left and the other is right on the same line? Why is this so hard? Is there something like LaTeX\'s \\hfill that can consume

9条回答
  •  无人及你
    2020-11-27 12:06

    I think one possible solution to this is to use display: table:

    .header {
      display: table;
      width: 100%;
      box-sizing: border-box;
    }
    
    .header > * {
      display: table-cell;
    }
    
    .header > *:last-child {
      text-align: right;  
    }
    
    h1 {
      font-size: 32px;
    }
    
    nav {
      vertical-align: baseline;
    }
    

    JSFiddle: http://jsfiddle.net/yxxrnn7j/1/

提交回复
热议问题