我正在使用 will_paginate 进行分页,并使用代码根据 Digg 使用的样式设置分页链接的样式。这是“指南”的链接。我正在尝试使分页居中对齐,但似乎无法获得指向中心的实际链接。我尝试将它们包装在自己的 div 中并做 margin: auto; 但链接仍然保持左对齐。在此先感谢,这是 rails 和 css 代码:
导轨
<div class="pagination">
<div class="page_info">
<%= page_entries_info @vars %>
</div>
<div class="pagination_links">
<%= will_paginate @vars, param_name: 'index_paginate', :container => false %>
</div>
</div>
CSS
.pagination {
background: white;
cursor: default;
/* self-clearing method: */ }
.pagination a, .pagination span, .pagination em {
padding: 0.2em 0.5em;
display: block;
float: left;
margin-right: 1px; }
.pagination .disabled {
color: #999999;
border: 1px solid #dddddd; }
.pagination .current {
font-style: normal;
font-weight: bold;
background: #2e6ab1;
color: white;
border: 1px solid #2e6ab1; }
.pagination a {
text-decoration: none;
color: #105cb6;
border: 1px solid #9aafe5; }
.pagination a:hover, .pagination a:focus {
background: white;
color: #000044;
border-color: #000044; }
.pagination .pagination_links {
margin: 0 auto;
width: 70%;
text-align: center;
}
.pagination .page_info {
margin: 0 auto;
background: #2e6ab1;
color: white;
padding: 0.4em 0.6em;
width: 22em;
margin-bottom: 0.3em; }
.pagination .page_info b {
color: #000033;
background: #6aa6ed;
padding: 0.1em 0.25em; }
.pagination:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden; }
* html .pagination {
height: 1%; }
*:first-child + html .pagination {
overflow: hidden; }
更新:我是 CSS 新手,我认为 div 会根据其内容自动调整大小。我一直在寻找一个解决方案来解决这个问题。在我意识到我在寻找什么之后,我用谷歌搜索并找到了答案。