为分页超链接添加空间

时间:2017-06-26 07:08:45

标签: css

我正在尝试为分页数字添加空格

我的php看起来像这样

    echo "<ul class='pagination'>";
    echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."'             class='button'>Previous</a>"; 

    for ($i=1; $i<=$total_pages; $i++) {  
    echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
    };  

    echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
    echo "</ul>"; 

输出看起来有点像

Previous12345678NEXT

如何添加空格?

3 个答案:

答案 0 :(得分:0)

 echo "<ul class='pagination'>";
    echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."'             class='button'>Previous</a>"; 
echo ' ';

    for ($i=1; $i<=$total_pages; $i++) {  
    echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
echo ' '; 
    };  

    echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
    echo "</ul>"; 

答案 1 :(得分:0)

尝试以下代码。

<?php
echo "<ul class='pagination'>";
echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."' class='button'>Previous </a>"; 

for ($i=1; $i<=5; $i++) {  
    echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i." </a>";
};  

echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
echo "</ul>"; 
?>

答案 2 :(得分:-1)

如果在网站上使用bootstrap,那么在标签中添加pull-left和pull-right类,例如:

echo "<ul class='pagination'>";
    echo "<a style="text-decoration:none" href='dashboard.php?page=".($page-1)."'             class='button pull-left'>Previous</a>"; 

    for ($i=1; $i<=$total_pages; $i++) {  
    echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
    };  

    echo "<a style="text-decoration:none" href='dashboard.php?page=".($page+1)."' class='button pull-right'>NEXT</a>";
    echo "</ul>"; 

如果您没有引导程序,请使用此代码

echo "<ul class='pagination'>";
    echo "<a style="text-decoration:none; float:left" href='dashboard.php?page=".($page-1)."'             class='button'>Previous</a>"; 

    for ($i=1; $i<=$total_pages; $i++) {  
    echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
    };  

    echo "<a style="text-decoration:none; float:right" href='dashboard.php?page=".($page+1)."' class='button '>NEXT</a>";
    echo "</ul>";