jquery - 如何更改文本中制表符的大小?

标签 jquery html css

是否可以更改选项卡的大小?例如,当您有 <textarea> 时,如何才能使选项卡的尺寸变小? 据我所知,空格是一列,制表符通常是 4 列。如何使选项卡只占用 3 列字符空间?

Normal tab size: | |

Wanted tab size: | |

这将有助于更清晰地显示代码。此外,它还会使(导出的)文件大小保持较小(因为 1 个 Tab 字符小于 3 个 Space 字符)。

我不知道从哪里开始,也没有在互联网上找到任何东西。因此,我们将非常感谢您的每一次帮助。

最佳答案

我想您可能正在寻找 tab-size (MDN 链接)

The tab-size CSS property is used to customize the width of a tab (U+0009) character.

Wikipedia

In CSS, tabs are preserved in an element as shown above if the attribute white-space set to pre. CSS 3 defines tab-size property, which adjusts the number of spaces for the tab character from the default of 8. The latest version of WebKit supports the tab-size property. The Opera web browser supports the -o-tab-size CSS property, the Firefox web browser supports the -moz-tab-size CSS property with the same meaning.

注:Support 较差(尽管 MS Edge 正在考虑该属性,但 IE 的支持为零)。

关于jquery - 如何更改文本中制表符的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34090866/

相关文章:

html - 在 HTML 中对齐图像组

html - 列表元素底部

CSS 根据最近类的属性更改颜色

jQuery 仅适用于 Chrome

javascript - 在 jquery.live() 中声明可在所有函数中使用的 var

JQuery Tablesorter 文本提取未按预期工作

java xml 解析器异常 : The end-tag for element type "col" must end with a '>' delimiter

html - Safari 中的顶部边距可移除,但 Firefox 中不可移除

javascript - 拖过absolute元素时,一直触发drag leave事件

javascript - 使用 AJAX 和 PHP 将数据插入 MySQL