
例如,假设我有一段代码出现在< pre>中.在网页上:
function Image(){ this.Write = function() { document.write(this.ToString()); return this; }; ...}Image.prototype = new PropertIEs();... 是否可以使用CSS指定标签缩进行的不同空间量?
如果没有,是否有任何变通方法?
解决方法 来自CSS 2.1,§ 16.6.1 The ‘white-space’ processing model:All tabs (U+0009) are rendered as a horizontal shift that lines up the start edge of the next glyph with the next tab stop. Tab stops occur at points that are multiples of 8 times the wIDth of a space (U+0020) rendered in the block’s Font from the block’s starting content edge.
CSS3 Text说的基本相同.
来自HTML 4.01 § 9.3.4 Preformatted text: The PRE element
The horizontal tab character (decimal 9 in [ISO10646] and [ISO88591] ) is usually interpreted by visual user agents as the smallest non-zero number of spaces necessary to line characters up along tab stops that are every 8 characters. We strongly discourage using horizontal tabs in preformatted text since it is common practice,when editing,to set the tab-spacing to other values,leading to misaligned documents.
如果您关注前导标签,则用空格替换它们是一件简单的事情.
/* repeat implemented using Russian Peasant multiplication */String.prototype.repeat = function (n) { if (n<1) return ''; var accum = '',c=this; for (; n; n >>=1) { if (1&n) accum += c; c += c; } return accum;}String.prototype.untabify = function(tabWIDth) { tabWIDth = tabWIDth || 4; return this.replace(/^\t+/gm,function(tabs) { return ' '.repeat(tabWIDth * tabs.length)} );} 总结 以上是内存溢出为你收集整理的html – 使用CSS控制选项卡空间?全部内容,希望文章能够帮你解决html – 使用CSS控制选项卡空间?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)