指定制表位宽度? [英] Specifying Tab-Width?

查看:107
本文介绍了指定制表位宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在显示空格时(例如在< pre>标记或某事物中)定义标签页宽度?我找不到任何东西做这个与CSS,但这似乎是一个很常见的事情想做。

Is it possible to define the tab-width when whitespace is displayed (say within a <pre> tag or something)? I can't find anything to do this with CSS, but this seems like it would be a pretty common thing to want to do.

在我的情况下,标签宽度是这么宽,它导致我的一些页面上的代码段太宽。如果我能以某种方式缩短标签宽度,使其适合没有滚动条,这将使事情变得更容易。 (我想我可以用空格替换制表符,但理想的情况是我想找到一种方法来做这件事)

In my case, the tab width is so wide that it causes some of my code snippets on a page to be too wide. If I could somehow shorten the tab-width to make it fit without scrollbars it would make things much easier. (I suppose I could just replace the tabs with spaces, but ideally I would love to find a way to do this without doing that)

推荐答案

我相信这博客文章应该可以帮助您:

I believe this blog post should help you out:


这里有一个解决方案,它不整洁,因为它必须为每个选项卡实例,但它使标签占用更少的空间,保留用于复制浏览器的格式(显然用实际的标签替换A SINGLE TAB HERE),该博客软件自动从条目中移除标签):

Here's a solution, it's not neat since it has to be done for every instance of a tab, but it makes the tabs take up less space and preserves the formatting for copying out of the browser (obviously replace "A SINGLE TAB HERE" with a real tab, this blog software automatically removes tabs from entries it seems):



<span style="display:none">A SINGLE TAB HERE</span><span style="margin-left:YOUR NEW TAB WIDTH"></span>




基本上,用代码替换代码中的每个选项卡实例snippet(在选择合适的宽度后,你可以很容易地在样式表中做)。

Basically, replace every instance of a tab in your code with that code snippet (after choosing a suitable width, you could do it in a stylesheet pretty easily). The code artificially inserts the margin whilst keeping the original tab in the code ready for copy/pasting.

顺便说一下,它看起来像制表符进入 CSS规范

Incidentally, it looks like tab stops made it into the CSS specification.

还有一个Stack Overflow问题

There's also another Stack Overflow question on this subject.

这篇关于指定制表位宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆