Removing float
s, and using inline-block
may fix your problems:
(删除float
并使用inline-block
可能会解决您的问题:)
.pagination a {
- display: block;
+ display: inline-block;
width: 30px;
height: 30px;
- float: left;
margin-left: 3px;
background: url(/images/structure/pagination-button.png);
}
(remove the lines starting with -
and add the lines starting with +
.)
((删除以-
开头的行,并添加以+
开头的行。))
.pagination { text-align: center; } .pagination a { + display: inline-block; width: 30px; height: 30px; margin-left: 3px; background: url(/images/structure/pagination-button.png); } .pagination a.last { width: 90px; background: url(/images/structure/pagination-button-last.png); } .pagination a.first { width: 60px; background: url(/images/structure/pagination-button-first.png); }
<div class='pagination'> <a class='first' href='#'>First</a> <a href='#'>1</a> <a href='#'>2</a> <a href='#'>3</a> <a class='last' href='#'>Last</a> </div> <!-- end: .pagination -->
inline-block
works cross-browser, even on IE6 as long as the element is originally an inline element.
(inline-block
即使在IE6上也可以跨浏览器运行,只要该元素最初是一个inline元素即可。)
Quote from quirksmode :
(从quirksmode引用:)
An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a block.
(内联块被内联放置(即,与相邻内容位于同一行),但是它的行为就像一个块。)
this often can effectively replace floats:
(这通常可以有效地替换浮点数:)
The real use of this value is when you want to give an inline element a width.
(该值的真正用途是当您要向内联元素赋予宽度时。)
From the W3C spec :
(根据W3C规范 :)
[inline-block] causes an element to generate an inline-level block container.
([inline-block]使元素生成一个内联级别的块容器。)
The inside of an inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box. (内联块的内部被格式化为块框,元素本身被格式化为原子内联级别框。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…