我应该把下面的代码放在哪里以获得类似" https://codepen.io/Zeaklous/pen/kyGqm"的动画。围绕我的产品
<div class="svg-wrapper">
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<rect class="shape" height="140" width="140" />
</svg>
css 我在我的css文件中添加了
.svg-wrapper svg{
position: absolute;
top: 0;
left: 0;
}
.svg-wrapper {
width: 140px;
height: 140px;
position: relative;
display: inline-block;
cursor: pointer;
margin: 0 auto;
}
.shape {
stroke-dasharray: 0 540;
stroke-dashoffset: -474;
stroke-width: 1px;
fill: transparent;
stroke: #000;
transition: stroke-width 1s, stroke-dashoffset 1s, stroke-dasharray 1s;
}
.svg-wrapper:hover .shape {
stroke-width: 2px;
stroke-dashoffset: 0;
stroke-dasharray: 900;
}
我想在其中包含上述代码的产品页面如下:
{$number_line = 1}
{$id_lang = Context::getContext()->language->id}
{foreach from=$group_cat_info item=cat_info name=g_cat_info}
<div class="block-content">
<div id="wt-prod-cat-{$cat_info.id_cat}" class="row">
<div class="cat-bar col-sm-12">
<div class="out-wt-prod">
{if $cat_info.cat_icon!='' }
<div class="icon_cat" style="background-color:{$cat_info.cat_color|escape:'html':'UTF-8'}">
<img src="{$icon_path|escape:'html':'UTF-8'}{$cat_info.cat_icon|escape:'html':'UTF-8'}" alt=""/>
</div>
{/if}
<h3><a href="{$link->getCategoryLink($cat_info.id_cat, $cat_info.link_rewrite)|escape:'html':'UTF-8'}" title="{$cat_info.cat_name|escape:'html':'UTF-8'}">{$cat_info.cat_name|escape:'html':'UTF-8'}</a></h3>
</div>
</div>
{if $group_cat.show_sub == 1}
<div class="sub-cat wt-col-md-2">
<ul class="sub-cat-ul">
{foreach from = $cat_info.sub_cat item=sub_cat name=sub_cat_info}
<li><a href="{$link->getCategoryLink($sub_cat.id_category, $sub_cat.link_rewrite)|escape:'html':'UTF-8'}" title="{$sub_cat.name|escape:'html':'UTF-8'}">{$sub_cat.name|escape:'html':'UTF-8'}</a></li>
{/foreach}
{if isset($cat_info.special_prod_obj) && count($cat_info.special_prod_obj)}
{$cat_product = $cat_info.special_prod_obj}
{$id_lang = Context::getContext()->language->id}
<li class="wt-prod-special">
<a class="product_img_link" href="{$link->getProductLink($cat_product)|escape:'html':'UTF-8'}" title="{$cat_product->name[$id_lang]|escape:'html':'UTF-8'}">
<img class="replace-2x img-responsive" src="{$link->getImageLink($cat_product->link_rewrite[$id_lang], $cat_product->id_image, 'home_default')|escape:'html':'UTF-8'}" alt="" title="{$cat_product->name[$id_lang]|escape:'html':'UTF-8'}"/>
</a>
</li>
{/if}
</ul>
</div>
{/if}
<div class="product_list wt-col-md-12 wt-col-sm-12">
<div class="owl-prod-cat">
{if isset($cat_info.product_list) && count($cat_info.product_list) > 0}
{foreach from=$cat_info.product_list item=product name=product_list}
{if $smarty.foreach.product_list.iteration % $number_line == 1 || $number_line == 1}
<div class="item product-box ajax_block_product">
{/if}
<div class="product-container">
<div class="product-container-hover">
<h5 class="product-name"><a href="{$product.link|escape:'html'}">{$product.name|truncate:25:''|escape:'html':'UTF-8'}</a></h5>
{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
<div class="content_price">{hook h='displayProductListFunctionalButtons' product=$product}
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
<span class="price product-price">
{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
</span>
{if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
{hook h="displayProductPriceBlock" product=$product type="old_price"}
<span class="old-price product-price">
{displayWtPrice p=$product.price_without_reduction}
</span>
{hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
{if $product.specific_prices.reduction_type == 'percentage'}
<span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
{/if}
{/if}
{hook h="displayProductPriceBlock" product=$product type="price"}
{hook h="displayProductPriceBlock" product=$product type="unit_price"}
{/if}
</div>
{/if}
<div class="product-image-container">
<a class="product_img_link" href="{$product.link|escape:'html'}" title="{$product.legend|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" alt="{$product.legend|escape:html:'UTF-8'}"height="140" width="140" /></a>
</div>
<div class="">
<div class="button-container">
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if (!isset($product.customization_required) || !$product.customization_required) && ($product.allow_oosp || $product.quantity > 0)}
{capture}add=1&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}{/capture}
<a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity > 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}">
<span>{l s='Add to cart' mod='wtproductcategory'}</span>
</a>
{else}
<span class="button ajax_add_to_cart_button btn btn-default disabled">
<span>{l s='Out of stock' mod='wtproductcategory'}</span>
</span>
{/if}
{/if}
</div>
</div>
</div>
</div>
{if $smarty.foreach.product_list.iteration % $number_line == 0 ||$smarty.foreach.product_list.last || $number_line == 1}
</div>
{/if}
{/foreach}
{else}
<div class="item product-box ajax_block_product">
<p class="alert alert-warning">{l s='No product at this time' mod='wtproductcategory'}</p>
</div>
{/if}
</div>
{if count($cat_info)>0}
<div class="manu-list">
<ul>
{foreach from=$cat_info.manufacture item=manu_item name=manufacture}
<li><a href="#">{$manu_item->name|escape:'html':'UTF-8'}</a></li>
{/foreach}
</ul>
</div>
{/if}
</div>
</div>
</div>
{if $cat_info.show_img == 1 && isset($cat_info.id_image) && $cat_info.id_image > 0}
<div class="cat-img">
<a href="{$link->getCategoryLink($cat_info.id_cat, $cat_info.link_rewrite)|escape:'html':'UTF-8'}" title="{$cat_info.cat_name|escape:'html':'UTF-8'}">
<img src="{$link->getCatImageLink($cat_info.link_rewrite, $cat_info.id_image, 'category_default')|escape:'html':'UTF-8'}"/>
</a>
</div>
{/if}
{/foreach}
答案 0 :(得分:1)
我不太了解产品页面代码但是
如果你想要menu list
这就是代码:
<div class="svg-wrapper">
<svg height="60" width="320" xmlns="http://www.w3.org/2000/svg">
<rect class="shape" height="60" width="320" />
<div class="manu-list">
<ul>
{foreach from=$cat_info.manufacture item=manu_item name=manufacture}
<li><a href="#">{$manu_item->name|escape:'html':'UTF-8'}</a></li>
{/foreach}
</ul>
</div>
</svg>
</div>
对于添加到购物车按钮:
<div class="svg-wrapper">
<svg height="60" width="320" xmlns="http://www.w3.org/2000/svg">
<rect class="shape" height="60" width="320" />
<div class="button-container">
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if (!isset($product.customization_required) || !$product.customization_required) && ($product.allow_oosp || $product.quantity > 0)}
{capture}add=1&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}{/capture}
<a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity > 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}">
<span>{l s='Add to cart' mod='wtproductcategory'}</span>
</a>
{else}
<span class="button ajax_add_to_cart_button btn btn-default disabled">
<span>{l s='Out of stock' mod='wtproductcategory'}</span>
</span>
{/if}
{/if}
</div>
</svg>
</div>
更新:
在我检查了您的网站并使用页面源代码中的html代码后,我就这样做了
在img
代码
<div class="svg-wrapper">
<svg height="140" width="140" xmlns="http://www.w3.org/2000/svg">
<rect class="shape" height="140" width="140" />
并在img
代码
所以结果应该是这样的:
<a class="product_img_link" href="{$product.link|escape:'html'}" title="{$product.legend|escape:html:'UTF-8'}">
<div class="svg-wrapper">
<svg height="140" width="140" xmlns="http://www.w3.org/2000/svg">
<rect class="shape" height="140" width="140" />
<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" alt="{$product.legend|escape:html:'UTF-8'}"height="140" width="140" />
</svg>
</div>
</a>
您必须为img
标记添加填充以使svg正常显示,
你需要添加超过14的填充;新的CSS必须在你的所有CSS之后
如前:
img{
padding:15px;
}