分页链接的CSS
我想知道如何格式化搜索结果的以下分页。
这是分页代码:
//Create and print the Navigation bar
$nav="";
$next = $page+1;
$prev = $page-1;
if($page > 1) {
$nav .= "<div class=\"search_mainpg\"><div class=\"searchpage\" style=\"width:5%;\"><a onclick=\"showPage('','$prev'); return false;\" href=\"$self?page=" . $prev . "&q=" .urlencode($search_result) . "\">< Prev</a></div>";
$first = "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('','1'); return false;\" href=\"$self?page=1&q=" .urlencode($search_result) . "\"> << </a></div>" ;
}
else {
$nav .= " ";
$first = " ";
}
for($i = 1 ; $i <= $numpages ; $i++) {
if($i == $page) {
$nav .= "<b>$i</b>";
}else{
$nav .= "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('',$i); return false;\" href=\"$self?page=" . $i . "&q=" .urlencode($search_result) . "\">$i</a></div>";
}
}
if($page < $numpages) {
$nav .= "<div class=\"searchpage\" style=\"width:5%;\"><a onclick=\"showPage('','$next'); return false;\" href=\"$self?page=" . $next . "&q=" .urlencode($search_result) . "\">Next ></a></div>";
$last = "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('','$numpages'); return false;\" href=\"$self?page=$numpages&q=" .urlencode($search_result) . "\"> >> </a></div></div>";
}
else {
$nav .= " ";
$last = " ";
}
echo $first . $nav . $last;
目前,它显示如下:
alt text http://img227 .imageshack.us/img227/2765/paginate.jpg
i'd like a basic idea of how to go about formatting the following paging of the search result.
this is the paging code:
//Create and print the Navigation bar
$nav="";
$next = $page+1;
$prev = $page-1;
if($page > 1) {
$nav .= "<div class=\"search_mainpg\"><div class=\"searchpage\" style=\"width:5%;\"><a onclick=\"showPage('','$prev'); return false;\" href=\"$self?page=" . $prev . "&q=" .urlencode($search_result) . "\">< Prev</a></div>";
$first = "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('','1'); return false;\" href=\"$self?page=1&q=" .urlencode($search_result) . "\"> << </a></div>" ;
}
else {
$nav .= " ";
$first = " ";
}
for($i = 1 ; $i <= $numpages ; $i++) {
if($i == $page) {
$nav .= "<b>$i</b>";
}else{
$nav .= "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('',$i); return false;\" href=\"$self?page=" . $i . "&q=" .urlencode($search_result) . "\">$i</a></div>";
}
}
if($page < $numpages) {
$nav .= "<div class=\"searchpage\" style=\"width:5%;\"><a onclick=\"showPage('','$next'); return false;\" href=\"$self?page=" . $next . "&q=" .urlencode($search_result) . "\">Next ></a></div>";
$last = "<div class=\"searchpage\" style=\"width:2%;\"><a onclick=\"showPage('','$numpages'); return false;\" href=\"$self?page=$numpages&q=" .urlencode($search_result) . "\"> >> </a></div></div>";
}
else {
$nav .= " ";
$last = " ";
}
echo $first . $nav . $last;
currently, it displays like this:
alt text http://img227.imageshack.us/img227/2765/paginate.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
div 具有 display:block 的 CSS 属性,这意味着它们尝试水平填充,
您应该在所有 div 上尝试 float:left 或 display:inline
divs have a CSS property of display:block, which means they try to fill horizontally
you shoudl try float:left on all your divs, or display:inline
这是分页示例的来源 LINK
这里是一种轻弹类型的分页
CSS:
HTML:
这是类似挖掘的分页
CSS:
HTML:
但如果没有您想要的示例,很难弄清楚您想要什么。
Here's a source for pagination examples LINK
Here is a flick type of pagination
CSS:
HTML:
and this is digg-like pagination
CSS:
HTML :
but without an example of what you want it's difficult to figure out what you want.
尝试将
标记更改为
。
div
是块标签,而span
是内联标签。就像与
一样,其中一个设计为在 & 上方放置空间。吹掉内容,另一个只是修改视图。
另一件事是,您使用
$i
将当前的加粗。这也应该是span
或div
或您正在使用的任何内容,以便您稍后可以通过 CSS 轻松修改它。Try changing the
<div>
tags to<span>
instead.div
is a block tag, whereasspan
is inline. Think like<p></p>
versus<i></i>
where the one is designed to put space above & blow the content, the other just modifies the view.One other thing, is that you use
<b>$i</b>
to bold the current one. This should also be aspan
ordiv
or whatever you're using, so you can easily modify it by CSS later on.