根據MDN的tab-size頁面,正確的格式是:
tab-size: 4;
-moz-tab-size: 4;
-o-tab-size: 4;
JavaScript的回退:
var fix_tab_size = function(pre, size) {
if(typeof fix_tab_size.supports === 'undefined') {
var bs = document.body.style;
fix_tab_size.supports = ('tab-size' in bs || '-o-tab-size' in bs || '-ms-tab-size' in bs || '-moz-tab-size' in bs);
}
if(!fix_tab_size.supports) {
if(typeof pre.each === 'function') { //jquery
$('pre').each(function() {
var t = $(this);
t.html(t.html().replace(/\t/g, new Array(size+1).join(' ')));
});
} else if(typeof pre.innerHTML === 'string') {
pre.innerHTML = pre.innerHTML.replace(/\t/g, new Array(size+1).join(' '));
}
}
}
$(function() {
fix_tab_size($('pre'),4);
//or
$.getJSON(src, function(data) {
fix_tab_size($data_pre.html(data.code)); //etc
});
});
爲什麼沒有這一點,塊垂直方向的CSS3中心微不足道?基本佈局比圓角更有用。 – mcandre