I'm implementing pagination, and it needs to be centered.
(我正在实现分页,它需要居中。)
The problem is that the links need to be displayed as block, so they need to be floated.(问题在于链接需要显示为块,因此它们需要浮动。)
But then,text-align: center;
(但是然后, text-align: center;
)
(对他们不起作用。)
I could achieve it by giving the wrapper div padding of left, but every page will have a different number of pages, so that wouldn't work.(我可以通过给左边的wrapper div填充来实现,但是每个页面都有不同数量的页面,所以这是行不通的。)
Here's my code:(这是我的代码:)
.pagination { text-align: center; } .pagination a { display: block; width: 30px; height: 30px; float: left; 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 -->
To get the idea, what I want:
(为了得到这个主意,我想要什么:)
ask by Mike translate from so