[英]How to make letter spacing css rule add space around character?
In css letter-spacing
rule, the rule adds space after the character. 在css
letter-spacing
规则中,规则在字符后面添加空格。 Now I want to make the space to surround the character instead. 现在我想让空间围绕角色。 Importantly, when I highlight the whole text, the space before first character should be highlighted.
重要的是,当我突出显示整个文本时,应突出显示第一个字符前的空格。
Workarounds that I know: 我知道的解决方法:
Use margin-left and margin-right to adjust: 使用margin-left和margin-right进行调整:
It works, but highlighting text is broken (still does not highlight the space before the first character) 它有效,但突出显示的文字被破坏(仍然没有突出显示第一个字符前的空格)
Use left and right to position the text: Same issue 使用向左和向右定位文本:相同的问题
Instead of margin-left and margin-right you should use 你应该使用而不是margin-left和margin-right
.TEXTCLASS {
padding-left: SOMEVALUE ..... 2px;
padding-right: SOMEVALUE ..... 2px;
{
On idea is to add a hidden character at the start to create the space you want. 想法是在开头添加一个隐藏的角色来创建你想要的空间。
I will be using the zero width space character 我将使用零宽度空格字符
span { background:pink; font-size:25px; letter-spacing:20px; } span:before { content:"\\80"; }
<span>Some text here</span>
If you want to be able to select it you need to add it in the code: 如果您希望能够选择它,则需要在代码中添加它:
span { background:pink; font-size:25px; letter-spacing:20px; }
<span> Some text here</span>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.