打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
纯DIV+CSS实现京东商城分类(不需jquery)适合所有版本

第一步:在你所用的模板的css文件中加上以下代码

.my_left_category{
width:211px;
font-size:12px; 
}

.my_left_category h1{
background-image:url(images/spring_06.jpg);
height:20px;
background-repeat:no-repeat;
font-size:14px;
font-weight:bold;
padding-left:15px;
padding-top:8px;
margin:0px;
color:#FFF;
}

.my_left_category .my_left_cat_list{
width:209px;
border-color:#ce2020;
border-style:solid;
border-width:0px 1px 1px 1px;
line-height:13.5pt;
}
.my_left_category .my_left_cat_list h2 {
margin:0px;
padding:3px 5px 0px 9px;
}
.my_left_category .my_left_cat_list h2 a{
color:#d6290b;
font-weight:bold;
font-size:14px;
line-height:22px;
}

.my_left_category .h2_cat{
width:209px;
height:26px; 
background-image:url(images/my_menubg.gif);
background-repeat:no-repeat; 
line-height:26px;
font-weight:normal;
color:#333333;
position:relative;
}

.my_left_category a{
font:12px;
text-decoration:none;
color:#333333;
}
.my_left_category a:hover{
text-decoration:underline;
color:#ff3333;
}

.my_left_category h3{
margin:0px; 
padding:0px;
height:26px; 
font-size:12px; 
font-weight:normal;
display:block; 
padding-left:8px;
}
.my_left_category h3 span{color:#999999; width:145px; float:right;}
.my_left_category h3 a{ line-height:26px;}

.my_left_category .h3_cat{
display:none;
width:204px;
position:absolute; 
left:184px; 
margin-top:-26px; 
cursor:auto;
}

.my_left_category .shadow{
position:inherit;
background:url(images/shadow_04.gif) left top;
width:204px;
}

.my_left_category .shadow_border{
position:inherit; 
width:200px; 
border:1px solid #959595; margin-top:1px; 
border-left-width:0px; 
background:url(images/shadow_border.gif) no-repeat 0px 21px; 
background-color:#ffffff; 
margin-bottom:3px
}
.my_left_category .shadow_border ul{margin:0; padding:0; margin-left:15px}
.my_left_category .shadow_border ul li {
list-style:none;
padding-left:10px;
background-image:url(images/my_cat_sub_menu_dot.gif);
background-repeat:no-repeat;
background-position:0px 8px;
float:left;
width:75px;
height:26px;
overflow:hidden;
}

.my_left_category .active_cat{ z-index:99;background-position:0 -25px;cursor:pointer;}
.my_left_category .active_cat h3 { font-weight:bold}
.my_left_category .active_cat h3 span{ display:none;} 
.my_left_category .active_cat div{display:block;}

第二步:模板文件夹的library/category_tree.lbi内容改为:

<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<div class="my_left_category">
<h1>商品分类</h1>
<div class="my_left_cat_list">
{assign var="pre_item_level" value=-1}
<!--{foreach from=cat_list(0,0,false,3,false) item=cat}-->
{if $cat.level lt 2 && $pre_item_level gt 0}
</ul></div></div></div></div>
{/if}

{if $cat.level eq 0}
<h2><a href="{$cat.url}">{$cat.name|escape:html}</a></h2>
{elseif $cat.level eq 1}
<div class="h2_cat" onmouseover="this.className='h2_cat active_cat'" onmouseout="this.className='h2_cat'">
<h3><SPAN> - {$cat.cat_desc|escape:html}</SPAN><a href="{$cat.url}">{$cat.name|escape:html}</a></h3>
<div class="h3_cat">
<div class="shadow">
<div class="shadow_border">
<ul> 
{elseif $cat.level eq 2}
<li><a href="{$cat.url}">{$cat.name|escape:html}</a></li>
{/if}

{assign var="pre_item_level" value=$cat.level}
<!--{/foreach}-->
{if $pre_item_level gt 0}
</ul></div></div></div></div>
{/if}

</div>
</div>

第三步:把用到的图片拷贝到模板文件夹的images目录
ok完成!


注:
京东的二级分类名称旁边列了2个三级分类名称(灰色),作为三级分类的提示。参考其他网友的做法,这里使用二级类的描述字段cat_desc来实现,【用程序去调取二级类下的前两个三级分类完全是化简为烦的事情。】但这个效果要修改 /includes/lib_common.php 才生效的,当然,不修改也不会出错,只是没有显示罢了

修改方法:在/includes/lib_common.php 的cat_list函数中找到
$sql = "SELECT c.cat_id, c.cat_name,
修改为
$sql = "SELECT c.cat_id, c.cat_name, c.cat_desc,


补充一下:
在firefox等浏览器中,如果展开的部分被遮挡(由于父级容器overflow:hidden引起),在.my_left_category的样式中加上 position:absolute即可。

下一篇: 屏蔽ecshop云提示no_license 上一篇: IE6 png 透明 (三种解决方法)

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
div弹出层,带关闭功能
CSS+DIV怎么不叫它位置乱跑
基于jQuery加入购物车飞入动画特效
双边框的代码
梅竹新编图片模板4款//待用*****
CSS浮动布局初步
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服