Make lines of text have equal length

前端 未结 4 1061
刺人心
刺人心 2021-02-07 15:44

In centered h1 elements, if the text falls on multiple lines, line breaks make the text look like this:

                This is a header that takes          


        
4条回答
  •  别那么骄傲
    2021-02-07 16:31

    Late to this party, but here's my approach. I get the initial element height (any elements with the class balance_lines, in the code below), then incrementally shrink the width of the element. Once the height of the element changes, I've gone too far. The step before that should have lovely roughly-equal line lengths

提交回复
热议问题