广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > 如何更改ecshop中商品属性的效果

二次开发Ecshop二次开发

二次开发Ecshop二次开发

如何更改ecshop中商品属性的效果

关于ecshop商品属性,默认的效果是单选按钮的效果,非常的不好看。而现在商品属性选择的按钮都是主流边框效果的,那么如何将单选按钮更改成漂亮的边框效果呢?

1、首先我们找到商品详情页面(goods.dwt),找到代码

<!-- {foreach from=$spec.values item=value key=key} -->
<label for="spec_value_{$value.id}">
<input id="spec_value_{$value.id}" onclick="changePrice()" name="spec_{$spec_key}" type="radio" value="{$value.id}" />
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}] </label>
<!-- {/foreach} -->

更改为

 <div class="catt">
       <!-- {foreach from=$spec.values item=value key=key} -->
       <a {if $key eq 0}class="cattsel"{/if} onclick="changeAtt(this)" href="javascript:;" name="{$value.id}">{$value.label}<input style="display:none" id="spec_value_{$value.id}" type="radio" name="spec_{$spec_key}" value="{$value.id}" {if $key eq 0}checked{/if} /></a>
       <!-- {/foreach} -->
       </div>

2、添加js,找到代码

function changePrice() 在上面添加

function changeAtt(t) {
t.lastChild.checked='checked';
for (var i = 0; i<t.parentNode.childNodes.length;i++) {
 
        if (t.parentNode.childNodes[i].className == 'cattsel') {
           t.parentNode.childNodes[i].className = '';
        }
    }
t.className = "cattsel";
changePrice();
}

3、打开style.css,添加新的样式

/*--------------颜色选择器CSS添加-------------*/
.catt{width:100%; height:auto; overflow:hidden;}
.catt a{border: #c8c9cd 1px solid;  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:#CC0000 2px solid; background:#FFFFFF; margin-left:4px;margin-top:5px;}
.catt a:focus {outline-style:none;}
.catt .cattsel {border:#CC0000 2px solid; background: #FFFFFF url("images/test.gif") no-repeat bottom right; margin-left:4px;margin-top:5px;}
.catt .cattsel a:hover {border: #CC0000 2px solid; background: #FFFFFF url("images/test.gif") no-repeat bottom right;}

好了,赶紧看看,是不是很漂亮啊!