You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WooCommerce短代码问题:如何在价格与加入购物车按钮间加间距

商品价格与加入购物车按钮间距调整方案

你可以通过短代码的style参数直接添加内联样式解决间距问题,同时还能顺手去掉按钮默认边框,给你两种简单可行的方案:

  • 给价格加右边距:直接在style里针对价格元素设置间距,数值可以根据你的视觉需求调整

    [add_to_cart id="xx" style=".woocommerce-Price-amount { margin-right: 15px; }" show_price="true" quantity="1"]
    
  • 给按钮加左边距+移除默认边框:如果更倾向于调整按钮的位置,还能把去边框的样式一并写进去,不用单独留空style=""

    [add_to_cart id="xx" style=".single_add_to_cart_button { margin-left: 15px; border: none; }" show_price="true" quantity="1"]
    

要是内联样式不生效,就去WordPress后台「外观-自定义-额外CSS」里添加这段全局样式,所有使用该短代码的地方都会自动应用:

.woocommerce-add-to-cart .woocommerce-Price-amount {
    margin-right: 15px;
}
.woocommerce-add-to-cart .single_add_to_cart_button {
    border: none;
}

内容的提问来源于stack exchange,提问作者Elly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 14:35:55