2013-04-03 162 views
0

我想使用CSS對齊表中的數字時,括號用於顯示數字爲負值。就像你會在MS Word中使用小數點標籤一樣。CSS Div填充問題Internet Explorer

該CSS可以在IE6中運行,但我的問題是IE6-IE9在打印預覽中,或者打印頁面時右側支架填充變得大於指定值。在Chrome和Firefox中可以很好地進行打印。

任何人都可以指出我正確的方向來解決這個問題嗎?

代碼:

<html> 
<head> 
<title>Example</title> 
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.8.1/build/cssreset/cssreset-min.css" /> 
<style type="text/css"> 
/* Ignore stuff below */ 
html{ 
    font-family: arial, tahoma, sans-serif; 
    font-size: 12px; 
    line-height: 1.25em; 
    color: #333; 
    -webkit-font-smoothing: antialiased; 
    text-align: center; 
    background: #eee; 
} 
.wrapper{ 
    width: 780px; 
    margin: 10px auto; 
    padding: 10px; 
    background: #fff; 
} 
table{ 
    width: 100%; 
    font-size: 24px; 
    line-height: 1.25em; 
} 
h1{ 
    font-size: 18px; 
    line-height: 1.25em; 
    text-align: left; 
    background: #eee; 
    padding: 5px 10px; 
} 
/* Ignore stuff above */ 

.pR{ 
    padding-right: 10px; /* Needs to match width of .bracket below */ 
} 
.bracket{ 
    width: 10px; /* Needs to match padding-right of .pR above */ 
    text-align: center; 
    display: inline-block; 
    /* Fix for inline-block for IE 7 */ 
    zoom: 1; 
    *display: inline; 
} 
.right{ 
    text-align: right; 
} 
</style> 
</head> 
<body> 

<div class="wrapper"> 
<h1>With padding</h1> 
<table> 
<tr> 
<td class="right pR">1</td> 
</tr> 
<tr> 
<td class="right"><div class="bracket">(</div>1<div class="bracket">)</div></td> 
</tr> 
</table> 
</div> 
</body> 
</html> 
+0

使用跨度而不是div。 – matpol

+0

1.離開怪癖模式,2.張貼一個jsfiddle,所以我們可以很容易地看到你的意思。 – CBroe

+0

Matpol - Span感謝! CBroe - 我不能使用文檔類型,所以怪癖模式是一個問題。我不知道什麼是jsfiddle,但跨度似乎已經解決了這個問題 – user1607914

回答

0

沒有必要使用DIV。 使用span元素代替div。

Div是爲什麼創建問題的塊元素。