CSS: Left, Center, & Right Align Text on Same Line

前端 未结 8 869
借酒劲吻你
借酒劲吻你 2020-12-04 18:03

I need to left, center, & right align text on the same line. I have the following text:

  • Left Align: 1/10
  • Center: 02:27
  • R
8条回答
  •  温柔的废话
    2020-12-04 18:29

    Improvement on Pod's answer:

    #textbox {
        display: flex;
    }
    .alignleft {
        flex: 1;
        text-align: left;
    }
    .aligncenter {
        flex: 1;
        text-align: center;
    }
    .alignright {
        flex: 1;
        text-align: right;
    }

    1/10

    02:27

    100%

    This avoids the awkward box wrapping that occurs with floats on a small screen, as well as centering the middle text, in the middle of #textbox.

    JSFiddle:

    http://jsfiddle.net/secnayup/

提交回复
热议问题