Left/Right Alignment with Different Font Sizes in HTML

This question already has an answer here:

  • How to align content of a div to the bottom? 24 answers

  • Flexbox可以做到这一点...但它需要一个包装元素。

    .left {
      font-size: 300%;
    }
    
    div {
      width: 90%;
      margin: 1em auto;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      border-bottom: 2px solid grey;
    }
    <div>
      <span class="left">Left Alignment</span>
      <span class="right"> Right Alignment</span>
    </div>

    You can use flex-box with the align-items:baseline; property

    div{
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      padding: 10px;
    }
    
    .left{
        font-size: 300%;
    }
    <div>
    <span class="left">Left Alignment</span>
    <span class="right"> Right Alignment</span>
    </div>
    链接地址: http://www.djcxy.com/p/75788.html

    上一篇: 将文本对齐到div的底部

    下一篇: HTML中不同字体大小的左/右对齐