How to center-justify the last line of text in CSS?

后端 未结 10 1679
余生分开走
余生分开走 2020-12-02 08:23

How can I center-justify text?

Currently, justify does not center the last line.

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 09:07

    You can use the text-align-last property

    .center-justified {
        text-align: justify;
        text-align-last: center;
    }
    

    Here is a compatibility table : https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last#Browser_compatibility.

    Works in all browsers except for Safari (both Mac and iOS), including Internet Explorer.

    Also in Internet Explorer, only works with text-align: justify (no other values of text-align) and start and end are not supported.

提交回复
热议问题