How may I align text to the left and text to the right in the same line?

后端 未结 9 948
醉梦人生
醉梦人生 2020-12-12 12:37

How can I align text so that some of it aligns to the left and some of it aligns to the right within the same line?

This text should be left-aligned

相关标签:
9条回答
  • 2020-12-12 13:14
    <h1> left <span> right </span></h1>
    

    css:

    h1{text-align:left; width:400px; text-decoration:underline;}
    span{float:right; text-decoration:underline;}
    
    0 讨论(0)
  • 2020-12-12 13:16

    If you don't want to use floating elements and want to make sure that both blocks do not overlap, try:

    <p style="text-align: left; width:49%; display: inline-block;">LEFT</p>
    <p style="text-align: right; width:50%;  display: inline-block;">RIGHT</p>
    
    0 讨论(0)
  • 2020-12-12 13:17

    If you're using Bootstrap try this:

    <div class="row">
        <div class="col" style="text-align:left">left align</div>
        <div class="col" style="text-align:right">right align</div>
    </div>
    
    0 讨论(0)
  • 2020-12-12 13:21

    If you just want to change alignment of text just make a classes

    .left {
    text-align: left;
    }
    

    and span that class through the text

    <span class='left'>aligned left</span>
    
    0 讨论(0)
  • 2020-12-12 13:25

    Add span on each or group of words you want to align left or right. then add id or class on the span such as:

    <h3>
    <span id = "makeLeft"> Left Text</span>
    <span id = "makeRight"> Right Text</span>
    </h3>
    

    CSS-

    #makeLeft{
    float: left;
    }
    
    #makeRight{
    float: right;
    }
    
    0 讨论(0)
  • 2020-12-12 13:28

    HTML FILE:

    <div class='left'> Left Aligned </div> 
    <div class='right'> Right Aligned </div>
    

    CSS FILE:

    .left
    {
      float: left;
    }
    
    .right
    {
      float: right;
    }
    

    and you are done ....

    0 讨论(0)
提交回复
热议问题