简体   繁体   English

文本对齐对齐但向右?

[英]Text-align justify but to the right?

We want to make text-align:justify, to take all the width of the column, but it should start from the right side.我们想让 text-align:justify 占据列的所有宽度,但它应该从右侧开始。 Is there any way to make it with css or somehow?.有什么办法可以用 css 或以某种方式制作它吗?

EDIT:编辑:

As suggested http://jsfiddle.net/dVbJr/33/如建议http://jsfiddle.net/dVbJr/33/

.text {
  text-align: justify;
  direction:rtl;
}

works, but it has punctuation issue.有效,但它有标点符号问题。

SOLVED解决了

    <span style="float:right">...</span>

This to be attached in the end has solved the punctuation issue.最后附上这个,解决了标点问题。 Thanks for effort though to everyone!感谢大家的努力! I shall accept the first answer then.那么我将接受第一个答案。

I believe you might want something like this:我相信你可能想要这样的东西:

direction:rtl;
text-align:justify;

Example: http://jsfiddle.net/aew75/示例: http : //jsfiddle.net/aew75/

text-align-last: right;
-moz-text-align-last: right;

If I understand the question correctly, the issue is really just how to right-align the last line of a justified block of text.如果我正确理解了这个问题,那么问题实际上只是如何右对齐对齐文本块的最后一行。 The above does just that, using a property in CSS 3 Text (with a vendor prefix version for better support), supported by modern browsers though not universally.上面只是使用CSS 3 Text 中的属性(带有供应商前缀版本以获得更好的支持),现代浏览器虽然不普遍支持。

Though setting the writing direction to right-to-left causes this, among other things, it has several other, more fundamental effects.尽管将书写方向设置为从右到左会导致这一点,但它还有其他几个更基本的影响。 You may get away with it, if you don't ever have inherently right-to-left characters in the text.如果文本中从来没有固有的从右到左的字符,那么您可能会侥幸逃脱。

It can be solved by adding text-align-last:可以通过添加 text-align-last 来解决:

div.a {
    text-align: justify;  /* For Edge */
    text-align-last: right;
}

Source: link来源:链接

check this sample检查这个样本

for right-to-left you just need to set direction:rtl对于right-to-left您只需要设置direction:rtl

CSS CSS

text-align: justify; 
text-align: right; // or text-align: left right; 

Just try this.试试这个。

text-align:right justify;
direction:rtl; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM