我在尝试将 HTML Div 包装在创建分页链接的 php 部分时遇到了一些麻烦。
我将 div 包裹在代码周围,但由于某种原因,div 出现在分页链接之前(外部)。正如您所看到的,所有 CSS 目前正在做的就是在 div 周围放置一个边框。
我无法弄清楚我错过了什么。任何指针将不胜感激。先感谢您。
PHP/HTML
echo '<div class = "pagination">';
/****** build the pagination links ******/
// range of num links to show
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><div class = 'pagination_button'> << </div></a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><div class = 'pagination_button'> < </div></a> ";
}
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " <div class = 'pagination_button_current'><b>$x</b></div> ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'><div div class = 'pagination_button'>$x</div></a> ";
} // end else
} // end if
} // end for
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'><div div class = 'pagination_button'> > </div></a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'><div div class = 'pagination_button'> >> </div></a> ";
}
/****** end build pagination links ******/
?>
</div> <!-- End pagination div -->
CSS
.pagination {
border:1px solid;
}