2016-12-15 57 views
1

我想調整我的分頁,使它位於頁面的中心。即使我將它們放在同一個div中,它的某些部分也不會對齊。任何幫助,將不勝感激。謝謝。如何正確對齊我的分頁?

<div class="center"> 
<ul class="pagination"> 

<a>Page: </a> <?php echo $pages; if($_GET['category'] != ''){?> 
<a href="<?php echo $currentURL;?>View/All" 
<?php if($action == "ViewAll"){echo 'style="font-weight:bold;color:#000;text-decoration:none;"';}?>> 
View All</a><?php }?> 
</ul> 
</div>  
</div> 

<style> 

ul.pagination { 
display: inline-block; 
padding: 0; 
margin: 0; 
padding-top: 300px; 
} 

ul.pagination { 
} 


ul.pagination p{display: inline;} 

ul.pagination a { 
color: black; 
float: left; 
padding: 8px 16px; 
text-decoration: none; 
transition: background-color .3s; 
border: 1px solid #ddd; 
} 

ul.pagination p a.active { 
background-color: #4CAF50; 
color: white; 
border: 1px solid #4CAF50; 
} 

ul.pagination p a:hover:not(.active) {background-color: #ddd;} 



</style> 
+1

它可能會很有用,如果你用一些html內容替換php代碼,現在我在佈局中看到的唯一的東西是一個「Page:」和一個「View/All」矩形。你想要以此爲中心嗎? – sebasaenz

+0

你的'li'標籤在哪裏? 'a'不能是'ul'的直接子代:https://developer.mozilla.org/en/docs/Web/HTML/Element/ul –

回答

0

你的div默認會和頁面一樣寬(或者包含它的任何元素)。我們假設它比你的分頁寬。爲了集中它。

爲「ul」指定一個特定的寬度併爲其設置一個「margin:0 auto」。只要你不在裏面漂浮什麼東西,它就會把它自己放在容器(div)中。