text-justify 属性规定当 text-align 被设置为 text-align 时的齐行方法. 该属性规定如何对齐行文本进行对齐和分隔. inter-ideograph
意思为 "用表意文本来排齐内容."
实现文字两端对齐的效果:
- text-align:justify;
- text-justify:inter-ideograph;
如果没有效果, 可以用下面这个方法:
(推荐学习: CSS 视频教程 https://www.html.cn/css/ )
CSS 代码:
- div.justify {
- text-align: justify;
- width:200px;
- font-size:15px;
- color:red;
- border:1px solid blue;
- height:18px;
- }
- div.justify> span {
- display: inline-block /* Opera */;
- padding-left: 100%;
- }
HTML 代码: 注意那个 span 标签
- <div class="justify">
- hello, text justify.
- </div>
- <br/>
- <div class="justify">
- hello, text justify.
- <span>
- </span>
- </div>
- <br/>
- <div class="justify">
- 中 文 两 端 对 齐
- </div>
- <br/>
- <div class="justify">
- 中 文 两 端 对 齐
- < span>
- </span>
- </div>
最终效果图:
来源: http://www.css88.com/qa/css3/14866.html