单行中文如何实现两端对齐

text-align: justify可以实现英文的两端对齐,但是它有两个缺陷:

  1. 只对多行文本有效,并且多行文本的最后一行无效
  2. IE浏览器下只对英文有效

对于问题1,可以用 text-align-last: justify 解决,我自己测试在IE chrome firefox下都是有效果的;
对于问题2,可以用IE的私有属性 text-justify: inter-ideograph 解决。

最终解决方案:

.justify {
    text-align: justify;
    text-align-last: justify;
    text-justify: inter-ideograph;
}

猜你喜欢

转载自blog.csdn.net/shengandshu/article/details/73821806