我正在尝试使用CSS来对齐表中的数字,当使用括号将数字显示为负值时。就像您在MS Word中使用小数点制表符一样。
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>发布于 2013-04-05 13:36:03
不需要使用div。使用span元素代替div。
Div是创建问题的块元素。
https://stackoverflow.com/questions/15791091
复制相似问题