HTML/CSS: how to put text both right and left aligned in a paragraph

后端 未结 6 1676
情歌与酒
情歌与酒 2020-12-28 18:54

What would be the best code to have two bits of text in a single paragraph, one left aligned, the other right aligned, that also is:

  • the least code as possible
6条回答
  •  粉色の甜心
    2020-12-28 19:53

    enter image description here

    If the texts has different sizes and they must be underlined this is the solution:

    January 2014

    css:

    table{
        width: 100%;
        border-bottom: 2px solid black;
        /*this is the size of the small text's baseline over part  (≈25px*3/4)*/
        line-height: 19.5px; 
    }
    table td{
        vertical-align: baseline;
    }
    .left{
        font-family: Arial;
        font-size: 40px;
        text-align: left;
    
    }
    .right{
        font-size: 25px;
        text-align: right;
    }
    

    demo here

提交回复
热议问题