<div class="content_topp"> <div id="app-share-content">经常网友问商品的颜色尺 寸等属性选择,默认的是下拉菜单和点选两种形式,样式特别不耐看,淘宝选择那种方形的框选已经是主流,像shopex的属性选择就是仿淘宝那 种框选特别美观!下面分享一下ecshop修改成框选的经验:
根据模板不同,大家参考着修改模板,为避免出错,修改时请务必备份模板以涉及到被修改的文件!
首先演示下效果:
实现原理:
1:css控制本来要显示的radio为一小矩形.
2:当点击此小矩形时,js使此radio选中,同时改变此小矩形的外观样式.
涉及的修改文件,请做好备份(default模板为例)
/themes/default/style.css
/themes/default/goods.dwt
注:此路径为待修改模板路径(default修改为你的模板文件夹名称).
一:控制样式
1.打开/themes/default/images/
添加图片test.gif.
2.打开/themes/default/style.css
最下面添加:
/*--------------颜色选择器CSS添加-------------*/.catt{width:100%;height:auto;overflow:hidden;padding-bottom:5px;}.catt a{border:#c8c9cd1pxsolid;text-align:center;background-color:#fff;margin-left:5px;margin-top:6px;padding-left:10px;padding-right:10px;display:block;white-space:nowrap;color:#000;text-decoration:none;float:left;}.catt a:hover {border:#ED00362pxsolid;margin:-1px;margin-left:4px;margin-top:5px;}.catt a:focus {outline-style:none;}.catt.cattsel{border:#ED00362pxsolid;margin:-1px;background:url("images/test.gif")no-repeatbottomright;margin-left:4px;margin-top:5px;}.catt.cattsel a:hover {border:#ED00362pxsolid;margin:-1px;background:url("images/test.gif")no-repeatbottomright;}
3.打开/themes/default/goods.dwt
注:以下修改以原版ecshop2.7.2版本default(模板名称)为基准
未修改前第347-351行
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]
修改为:
{$value.label}
此处为是了将radio换成淘宝上那种小矩形样式显示在页面.
二:增加js控制样式与选中行为
在页面内找到
<p>function changePrice() 在其上面增加function changeAtt(t) {t.lastChild.checked='checked'; for (var i = 0; i |
|