且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我该如何在同一行中将文本与左边的文本和右边的文本对齐?

更新时间:2023-11-22 13:19:58

< p style = text-align:left;>此文本左对齐< span style =float:right;>此文本右对齐< / span>< / p> pre>



https://jsfiddle.net/gionaf/5z3ec48r/


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?

<p>This text should be left-aligned. This text should be right aligned.</p> 

I can align all of the text to the left (or to the right), either directly inline, or by using a stylesheet -

<p style='text-align: left'>This text should be left-aligned. 
    This text should be right aligned.</p>

How can I align the corresponding text to the left and to the right, while keeping it on the same line?

<p style="text-align:left;">
This text is left aligned
<span style="float:right;">This text is right aligned</span>
</p>

https://jsfiddle.net/gionaf/5z3ec48r/