1 回答
TA贡献1793条经验 获得超6个赞
这是标记的快速示例。您需要使用 css 进行样式设置。
html/php
<a href="<?php echo wc_get_cart_url(); ?>" class="basketicon" title="<?php _e( 'View your shopping cart' ); ?>">
<span class="basketicon__icon"></span>
<span class="basketicon__total">
<?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?>
</span>
</a>
CSS/SASS
.basketicon{
margin: 0 30px 0 0;
padding: 0 30px 0 0;
display: inline-flex;
align-items: center;
position: relative;
@media (min-width: $lg){
margin: 0 30px 0 0;
padding: 0 30px 0 0;
}
&::before{
@media (min-width: $lg){
content: '';
position: absolute;
right: -10px;
width: 20px;
height: 1px;
background: #fff;
}
}
&__icon{
&::before{
content: url(../images/basket.svg);
height: 10px;
width: 10px;
display: block;
}
}
&__total{
display: none;
color: #fff;
font-size: rem(16);
margin: 0 0 0 10px;
@media (min-width: $lg){
font-size: rem(12);
display: inline-block;
}
@media (min-width: $xl){
font-size: rem(14);
}
@media (min-width: $xxxl){
font-size: rem(15);
}
}
&:hover,
&:focus{
.basketicon{
&__icon{
&::before{
transform: scale(0.8);
}
}
}
}
}
- 1 回答
- 0 关注
- 126 浏览
添加回答
举报