简体   繁体   English

字母间距CSS后的内容

[英]content after letter-spacing css

My purpose is to have two letters in a pseudo-element's content, with a spacing of 1 pixel between each letter. 我的目的是在伪元素的内容中包含两个字母,每个字母之间的间距为1个像素。

I have tried the obvious, which is assigning a letter-spacing of 1 pixel: 我尝试了明显的做法,即分配了1个像素的letter-spacing

#tweetList > li > .blockstyle > blockquote p.tweettext:before{
    content: '\2018\2019';
    font-family: 'ocr';
    font-style: normal;
    font-weight: 400;
    position: absolute;
    font-size: 120px;
    top: 0px;
    left: -120px;
    color: rgba(26,114,189, 1);
    text-shadow: 7px 14px 10px rgba(0, 0, 0, 0.1);
    letter-spacing: 1px;
}

The problem is that the two apostrophes are not getting the desired spacing. 问题在于两个撇号未获得所需的间距。 Here's a snapshot of the result: 这是结果的快照:

结果撇号间距

And here's what I'm trying to achieve: 这是我想要实现的目标:

所需的单引号间距

How can it be done? 如何做呢?

Problem 问题

The issue lies within the glyph's width. 问题出在字形的宽度之内。 As each apostrophe letter is taking more space in width than the actual glyph, they seem departed. 由于每个撇号字母在宽度上都比实际字形占用更多的空间,因此它们似乎已离开。

Solution

To solve this, adjust the letter spacing by assigning a negative value, like so: 要解决此问题,请通过分配负值来调整字母间距,如下所示:

#tweetList > li > .blockstyle > blockquote p.tweettext:before{
    content: '\2018\2019';
    font-family: 'ocr';
    font-style: normal;
    font-weight: 400;
    position: absolute;
    font-size: 120px;
    top: 0px;
    left: -120px;
    color: rgba(26,114,189, 1);
    text-shadow: 7px 14px 10px rgba(0, 0, 0, 0.1);
    letter-spacing: -.2em; /* <-- */
}

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM