织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

Dedecms列表pagelist翻页按钮样式怎么解决

织梦园模板 / 2021-04-27 / 收藏

Dedecms列表pagelist翻页按钮的首页和尾页样式的解决办法

Dedecms列表页翻页按钮使用的是{dede:pagelist listitem=”index,end,pre,next,pageno” listsize=”10″/}生成html后列表页***页是

<li >首页</li>  
<li class="thisclass">1</li>  
<li><a href='news_2.html'>2</a></li>  
<li><a href='news_3.html'>3</a></li>  
<li><a href='news_2.html'>下一页</a></li>  
<li><a href='news_3.html'>末页</a></li>


***后一页是:

<li><a href='news_1.html'>首页</a></li>  
<li><a href='news_2.html'>上一页</a></li>  
<li><a href='news_1.html'>1</a></li>  
<li><a href='news_2.html'>2</a></li>  
<li class="thisclass">3</li>  
<li >末页</li>


默认模板的CSS样式表:

.dede_pages{
}
.dede_pages ul{
	float:left;
	padding:12px 0px 12px 16px;
}
.dede_pages ul li{
	float:left;
	font-family:Tahoma;
	line-height:17px;
	margin-right:6px;
}
.dede_pages ul li a{
	float:left;
	padding:2px 4px 2px;
	color:#666;
	border-bottom:1px solid #EEE;
}
.dede_pages ul li a:hover{
	color:#690;
	text-decoration:none;
	padding:2px 4px 1px;
	border-bottom:2px solid #690;
}
.dede_pages ul li.thisclass a,.pagebox ul li.thisclass a:hover{
	color:#F63;
	padding:2px 4px 1px;
	border-bottom:2px solid #F63;
	font-weight:bold;
}
.dede_pages .pageinfo{
	float:right;
	line-height:21px;
	padding:12px 10px 12px 16px;
	color:#999;
}
.dede_pages .pageinfo strong{
	color:#666;
	font-weight:normal;
	margin:0px 2px;
}

可以看到”.dede_pages ul li a“和”.dede_pages ul li.thisclass“都有padding:2px 4px 2px;属性但是”.dede_pages ul li“却没有。在”.dede_pages ul li“没有padding:2px 4px 2px;属性时<li >首页</li>和<li >尾页</li>这两个按钮就会比别的按钮小,想想这种情况是多么难看。

下面就对以上问题提供两种解决办法

***种方法通过CSS解决,这个解决办法就是不控制a标签只对li添加样式,代码如下:

.dede_pages ul {
}
.dede_pages ul li {
float:left;
height:18px;
line-height:18px;
padding:4px 10px;
margin-right:5px;
border:1px #b9cdff solid;
}
.dede_pages .thisclass {
background:#e3ebfe;
}

可以看到代码***简洁,但是对于用户体验来说不是很好,应为现在的按钮是li表现出来而不是a表现出来的,这样当用户点击在按钮却没点击到文字上就等于没点中。为了更好的用户体验我们需要另一种解决办法。

第二种方法修改dede:pagelist的相关文件arc.listview.class.php在include文件夹下:

打开arc.listview.class.php找到如下代码:

//获得上一页和主页的链接          
if($this->PageNo != 1)          
{              
$prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>rn";              
$indexpage="<li><a href='".str_replace("{page}",1,$tnamerule)."'>首页</a></li>rn";          
}          
else          
{              
$indexpage="<li >首页</li>rn";          
}          
//下一页,未页的链接          
if($this->PageNo!=$totalpage && $totalpage>1)          
{              
$nextpage.="<li><a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a></li>rn";              
$endpage="<li><a href='".str_replace("{page}",$totalpage,$tnamerule)."'>末页</a></li>rn";          
}          
else          
{              
$endpage="<li >末页</li>rn";          
}


分别修改$indexpage=”<li >首页</li>rn”;$endpage=”<li >末页</li>rn”;为$indexpage=”<li class=”thisclass”>首页</li>rn”;$endpage=”<li class=”thisclass”>末页</li>rn”;修改好之后{dede:pagelist listitem=”index,end,pre,next,pageno” listsize=”10″/}生成的html代码如下:

<li class="thisclass">首页</li>  
<li class="thisclass">1</li>  
<li><a href='news_2.html'>2</a></li>  
<li><a href='news_3.html'>3</a></li>  
<li><a href='news_2.html'>下一页</a></li>  
<li><a href='news_3.html'>末页</a></li>

第二种方法更简单还增加了用户体验度

PS:使用第二种方法就不需要修改CSS文件了。

相关故障问题

收缩