phi*_*hil 29 html css text-alignment
我试图证明这个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>
Run Code Online (Sandbox Code Playgroud)
但文字不合理!任何想法为什么?
谢谢你的帮助.
man*_*ire 35
您可以使用此处描述的解决方案:http: //blog.vjeux.com/2011/css/css-one-line-justify.html
这将证明单行是合理的,但后面会增加一个空格,所以如果你知道高度,你可以指定它overflow:hidden
来隐藏它并仍然得到理由.
.fulljustify {
text-align:justify;
}
.fulljustify:after {
content: "";
display: inline-block;
width: 100%;
}
#tagline {
height: 80px;
overflow: hidden;
line-height: 80px; /* vert-center */
}
Run Code Online (Sandbox Code Playgroud)
<p id="tagline" class="fulljustify">Blah blah blah</p>
Run Code Online (Sandbox Code Playgroud)
Bre*_*ett 31
如果您的文本不超过一行,则证明不会执行任何操作.你的文本必须换行到下一行,然后FIRST行将被证明,但不是第二行.
如果你想证明487px
你可以尝试使用word-spacing
你的四个单词css
.
我用过word-spacing:8em;
,bla bla bla bla
但你可以根据需要进行调整.
小智 6
Chrome不支持它,但在Firefox和IE中,您可以使用text-align-last: justify;
.对于跨浏览器的解决方案,我们必须使用@onemanarmy发布的内容;)
小智 5
尝试这个
对于div
div {
text-align:justify;
text-justify: inter-word;
text-align-last:center;
/* for IE9 */
-ms-text-align-last:center;
}
Run Code Online (Sandbox Code Playgroud)