简体   繁体   English

文本对齐证明不起作用

[英]text-align justify not working

I'm trying to justify the text within this p tag so that it perfectly fits the width of the p.我试图证明这个 p 标签中的文本是正确的,以便它完全适合 p 的宽度。

<p align="justify" style="text-align: justify !important; color:#fff; margin:0px; font-weight:bold; width:487px; border:Solid 1px red;">blah blah blah</p>

but the text just wont justify?但文字只是不能证明? any idea why?知道为什么吗?

thanks for any help.谢谢你的帮助。

You can use the solution described here: http://blog.vjeux.com/2011/css/css-one-line-justify.html您可以使用此处描述的解决方案: http://blog.vjeux.com/2011/css/css-one-line-justify.html

This will justify a single line but adds a space after, so if you know the height, you can specify it with overflow:hidden to conceal it and still get the justification.这将使单行对齐,但在之后添加一个空格,因此如果您知道高度,您可以使用overflow:hidden指定它来隐藏它并仍然得到对齐。

 .fulljustify { text-align:justify; }.fulljustify:after { content: ""; display: inline-block; width: 100%; } #tagline { height: 80px; overflow: hidden; line-height: 80px; /* vert-center */ }
 <p id="tagline" class="fulljustify">Blah blah blah</p>

If your text doesn't span more than one line, justifying doesn't do anything.如果您的文本不超过一行,则对齐不会做任何事情。 Your text has to wrap to the next line, and then the FIRST line will be justified, but not the second.您的文本必须换行到下一行,然后第一行将是合理的,但不是第二行。

Chrome doesn't support it but in Firefox and IE, you can use text-align-last: justify; Chrome 不支持,但在 Firefox 和 IE 中,您可以使用text-align-last: justify; . . For a cross-browser solution, we have to use what @onemanarmy posted;)对于跨浏览器解决方案,我们必须使用@onemanarmy 发布的内容;)

If you wanted to justify four words in 487px you could try using word-spacing in your css .如果您想证明 487px 中的四个单词,您可以尝试在487px css使用word-spacing

I used word-spacing:8em;我使用word-spacing:8em; for bla bla bla bla but you could adjust as necessary.对于bla bla bla bla ,但您可以根据需要进行调整。

http://jsfiddle.net/5RpQr/1/ http://jsfiddle.net/5RpQr/1/

try this尝试这个

for div对于 div

div {
text-align:justify;
text-justify: inter-word;
text-align-last:center;
/* for IE9 */
-ms-text-align-last:center;
}

There is also something similar, like display: flex;还有类似的东西,比如 display: flex; justify-content: space-around; justify-content:空间环绕; if you would wrap those texts in spans or divs如果您将这些文本包装在跨度或 div 中

In my case for < p > tag, works with easy way:在我的情况下 < p > 标签,使用简单的方法:

p {
  text-align: justify;
  text-justify: inter-word;
}

https://css-tricks.com/almanac/properties/t/text-justify/ https://css-tricks.com/almanac/properties/t/text-justify/

To make it look good on Chrome & opera (multiline justify looks bad on them)让它在 Chrome 和 opera 上看起来不错(多行对齐在它们上看起来很糟糕)

I use the following我使用以下

.fulljustify {
  text-align: justify;
  display: table-row;
  text-align-last: left;
}

Chrome solution: If you don't want to mess with the display properties (in my case aligning an anchor tag of a carousel img): Chrome 解决方案:如果您不想弄乱显示属性(在我的情况下对齐轮播 img 的锚标记):

text-align: -webkit-center;

You better try你最好试试

style="text-align:justifty;display:inline-block;"

Just use style="text-align:justify" .只需使用style="text-align:justify"
It works in all browsers.它适用于所有浏览器。

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

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