CSS如何实现文本同时左对齐和两端对齐?

7
有没有办法同时使文本左对齐和两端对齐呢?类似于左对齐的两端对齐。有没有实现这一点的方法?谢谢帮助。

同时两端对齐和左对齐的文本会是什么样子?它与两端对齐和右对齐的文本有何不同?它又与未进行左对齐的文本有何不同? - twsaef
我想让CSS文本左对齐和两端对齐同时实现,这可能吗? - Anees Ahmad
1
我们无法理解您所说的“同时左对齐”的意思。您能否发布一张图片,展示您期望的效果是什么样子? - bfavaretto
4
我觉得你不理解"justify"的意思。 "Justified" 的文本是左右对齐的,因此说想要左对齐毫无意义。 - Darko
5个回答

25
您可能正在寻找最后一行左对齐的方法:
  text-align: justify;
  text-align-last: left;

这应该是正确的答案,我不知道text-align-last属性。 - Pedro Uzcátegui

9

左对齐意味着文本的左边缘对齐。两端对齐意味着文本的左边缘和右边缘都对齐。因此,“左对齐和两端对齐”与“两端对齐”没有任何区别,所以你的问题对我们来说毫无意义。

左对齐:

Four-score and seven years ago, our fathers 
brought forth on this continent a new nation, 
conceived in liberty, and dedicated to the 
proposition that all men are created equal.

两端对齐:

Four-score  and  seven years  ago, our fathers 
brought forth on this continent a  new nation, 
conceived  in  liberty, and  dedicated to  the 
proposition that all men are created equal.

右对齐:

  Four-score and seven years ago, our fathers 
brought forth on this continent a new nation, 
   conceived in liberty, and dedicated to the 
  proposition that all men are created equal.
也许您还想实现其他类型的对齐方式?

7

“对齐”表示文本在两个边缘上对齐。然而,文本的最后一行仍将定位在左侧或右侧。

所以...

左对齐

Lorem Ipsum is simply dummy text of the printing and       |
typesetting industry. Lorem Ipsum has been the industry's  |
standard dummy text ever since the 1500s, when an unknown  |
printer took a galley of type and scrambled it to make a   |
type specimen book.                                        |

左对齐

(指文本)
                                                           |
Lorem  Ipsum  is  simply  dummy  text  of  the printing  and 
typesetting  industry. Lorem  Ipsum has been  the industry's 
standard dummy  text ever since  the 1500s, when  an unknown 
printer took  a galley of type  and scrambled  it to make  a 
type specimen book.                                        |
                                                           |

右对齐

(与屏幕右侧对齐)
                                                           |
Lorem  Ipsum  is  simply  dummy  text  of  the printing  and 
typesetting  industry. Lorem  Ipsum has been  the industry's 
standard dummy  text ever since  the 1500s, when  an unknown 
printer took  a galley of type  and scrambled  it to make  a 
                                         type specimen book.
                                                           |

过去我没有使用过这个功能,所以我不确定CSS是否支持您想要的特定行为。不过,我认为W3Schools上的这个链接会有所帮助:http://www.w3schools.com/cssref/css3_pr_text-justify.asp


你说得对,这个不能用CSS实现,但是你举的例子非常清晰。这应该是正确的答案。 - cfontanet

3

这是一张图片,它包含了左对齐(左上角)和两端对齐(右上角)的文本。

enter image description here

要获得左对齐文本,您需要在CSS中使用text-align: justify;。在最新版本的Chrome和IE中,您可以使用该CSS获取最后一行为左对齐的对齐文本。我不确定旧浏览器如何处理它。
Photoshop提供4种类型的对齐文本,完全对齐或最后一行左对齐、居中或右对齐,但是浏览器似乎只支持左对齐。对于从右到左的语言,它们可能具有右对齐文本。

3
两端对齐文本始终是“左右对齐”的。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接