Adjusting Kerning in CSS

前端 未结 6 947
死守一世寂寞
死守一世寂寞 2020-12-31 01:06

Is it possible with CSS to adjust kerning in CSS? I\'d like to be able to kern a block of text such that it will actually look like a block of text (both left and right edge

6条回答
  •  生来不讨喜
    2020-12-31 01:23

    What seems to be required is dynamic kerning, because what the Thread Opener and also I am/is in need is this: justify does block alignment, as good as possible, by adding space between the words, which leaves "holes" in the text block. Now take instead the line with left align (so no added space), calculate it's physical width, compare with block width available, divide the diffrence trough the number of letters in that line, then use this value as the letterspace addition. This will look more like a newspaper layout than only a text-align:justify. I have to say tho, I am not sure whether the lines in a textblock can be accessed "by line number" in a dynamic page layout, can it? edit: I tried that yesterday. I use innerHTML to read the content of a text block, then I split and copy it to an array of which each entry/line gets its own DIV tag and id. Then I ajust letterspacing accordingly. Only few of the newest browsers support subpixel-letterspacing, so it works only with medium to big sized fonts. The problem I run into is: due to no Subpixelsupport it works only to some degree, although nice looking, so I tried to additionally justify the result with the text-align attribute, but it's not working after I altered letterspacing.. Left and right alignement works, but not "justify", this one works only before the addition of letterspacing. Could be an opera problem. If I can fix this then I'll post the code.

    edit 2. it works now but for some reason I cannot post code here. that is from webkit 10.3.3.13 on mobile. Send me a message if you're interested in the code.

提交回复
热议问题