如何删除HTML中字符之间的空格?填充不工作

时间:2021-11-16 07:07:08

如何删除HTML中字符之间的空格?填充不工作

Why is there space(marked in red color) before the letter 'അ', even if I added padding as 0px?

为什么会有空间(红色标记)在信中“അ”之前,即使我添加填充为0 px ?

<span style="margin:0;padding:0;border:1px solid blue;font-size:128px">അ</span>

3 个解决方案

#1


6  

That space is part of the font. Use a negative letter-spacing margin-left on it in order to remove it.

这个空间是字体的一部分。使用一个负的字母间距的空白,以便删除它。

Example

例子

Note: this only moves the entire span a few px back. In reality, the space is still there and cannot be properly removed.

注意:这只会将整个跨度向后移动几个px。在现实中,空间仍然存在,不能被正确地移除。

#2


4  

In typography, spacing between characters is often adjusted due to esthetic and readability considerations. The spaces are there even in common ascii letters:

在排版技术中,由于考虑到美观和可读性,通常会调整字符之间的间距。甚至在普通的ascii字母中也有空格:

<span style="margin:0;padding:0;border:1px solid blue;font-size:128px;letter-spacing:0px;">a</span>

如何删除HTML中字符之间的空格?填充不工作

But the space is different because of different variables like what is the previous and next character.

但是空间是不同的,因为不同的变量,比如前一个字符和下一个字符。

You can achive some results by playing with negative padding and letter-spacing

通过使用负填充和字母间距,您可以获得一些结果

More info

更多信息

#3


0  

White spaces occur from working with inline positioning and spans are always inline elements. Solution here: https://css-tricks.com/fighting-the-space-between-inline-block-elements/

使用内联定位时会出现空格,而跨始终是内联元素。解决办法:https://css-tricks.com/fighting-the-space-between-inline-block-elements/

Have you looked at lettering.js? Its a jquery plug-in that works specifically for typography.

你看过信了吗,js?它是一个专门用于排版的jquery插件。

#1


6  

That space is part of the font. Use a negative letter-spacing margin-left on it in order to remove it.

这个空间是字体的一部分。使用一个负的字母间距的空白,以便删除它。

Example

例子

Note: this only moves the entire span a few px back. In reality, the space is still there and cannot be properly removed.

注意:这只会将整个跨度向后移动几个px。在现实中,空间仍然存在,不能被正确地移除。

#2


4  

In typography, spacing between characters is often adjusted due to esthetic and readability considerations. The spaces are there even in common ascii letters:

在排版技术中,由于考虑到美观和可读性,通常会调整字符之间的间距。甚至在普通的ascii字母中也有空格:

<span style="margin:0;padding:0;border:1px solid blue;font-size:128px;letter-spacing:0px;">a</span>

如何删除HTML中字符之间的空格?填充不工作

But the space is different because of different variables like what is the previous and next character.

但是空间是不同的,因为不同的变量,比如前一个字符和下一个字符。

You can achive some results by playing with negative padding and letter-spacing

通过使用负填充和字母间距,您可以获得一些结果

More info

更多信息

#3


0  

White spaces occur from working with inline positioning and spans are always inline elements. Solution here: https://css-tricks.com/fighting-the-space-between-inline-block-elements/

使用内联定位时会出现空格,而跨始终是内联元素。解决办法:https://css-tricks.com/fighting-the-space-between-inline-block-elements/

Have you looked at lettering.js? Its a jquery plug-in that works specifically for typography.

你看过信了吗,js?它是一个专门用于排版的jquery插件。