以 Shopify 的购买按钮为中心的问题
Issue centering Shopify's Buy Buttons
有人知道如何将这些 "Add to Cart" 按钮居中吗?
项目在这里:https://codepen.io/amberbydesign/pen/pdovpL
下面的代码是 Shopify 为链接到外部 JS 文件的 1 if 3 按钮生成的代码。
(我尝试添加 - display: block; margin: 0 auto; 到按钮,但它仍然不起作用)
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.async = true;
script.src = scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'neriumskincare-jp.myshopify.com',
apiKey: 'a8fcda28a0b70b31bbea1f51003e2dd9',
appId: '6',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product', {
id: [8038986699],
node: document.getElementById('product-component-5d341381aec'),
moneyFormat: '%24%7B%7Bamount%7D%7D',
options: {
"product": {
"variantId": "all",
"width": "240px",
"contents": {
"img": false,
"imgWithCarousel": false,
"title": false,
"variantTitle": false,
"price": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"styles": {
"product": {
"text-align": "left",
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0",
"margin-bottom": "50px"
}
},
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
"padding-left": "15px",
"padding-right": "15px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"quantityInput": {
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px"
},
"compareAt": {
"font-size": "12px"
}
},
"googleFonts": [
"Lato"
]
},
"cart": {
"contents": {
"button": true
},
"text": {
"title": "Your Shopping Cart",
"empty": "Your cart is empty"
},
"styles": {
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"footer": {
"background-color": "#ffffff"
}
},
"googleFonts": [
"Lato"
]
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": true,
"variantTitle": false,
"buttonWithQuantity": true,
"button": false,
"quantity": false
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
"padding-left": "15px",
"padding-right": "15px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"quantityInput": {
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px"
}
},
"googleFonts": [
"Lato"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Lato, sans-serif",
"background-color": "#a1d2e6",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"count": {
"font-size": "15px"
}
},
"googleFonts": [
"Lato"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
}
}
});
});
}
})();
/*]]>*/
display: block;
margin: 0 auto;
对我有用,甚至在你的代码笔中。
有人知道如何将这些 "Add to Cart" 按钮居中吗?
项目在这里:https://codepen.io/amberbydesign/pen/pdovpL
下面的代码是 Shopify 为链接到外部 JS 文件的 1 if 3 按钮生成的代码。
(我尝试添加 - display: block; margin: 0 auto; 到按钮,但它仍然不起作用)
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.async = true;
script.src = scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'neriumskincare-jp.myshopify.com',
apiKey: 'a8fcda28a0b70b31bbea1f51003e2dd9',
appId: '6',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product', {
id: [8038986699],
node: document.getElementById('product-component-5d341381aec'),
moneyFormat: '%24%7B%7Bamount%7D%7D',
options: {
"product": {
"variantId": "all",
"width": "240px",
"contents": {
"img": false,
"imgWithCarousel": false,
"title": false,
"variantTitle": false,
"price": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"styles": {
"product": {
"text-align": "left",
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0",
"margin-bottom": "50px"
}
},
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
"padding-left": "15px",
"padding-right": "15px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"quantityInput": {
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px"
},
"compareAt": {
"font-size": "12px"
}
},
"googleFonts": [
"Lato"
]
},
"cart": {
"contents": {
"button": true
},
"text": {
"title": "Your Shopping Cart",
"empty": "Your cart is empty"
},
"styles": {
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"footer": {
"background-color": "#ffffff"
}
},
"googleFonts": [
"Lato"
]
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": true,
"variantTitle": false,
"buttonWithQuantity": true,
"button": false,
"quantity": false
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"background-color": "#a1d2e6",
"font-family": "Lato, sans-serif",
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px",
"padding-left": "15px",
"padding-right": "15px",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"quantityInput": {
"font-size": "15px",
"padding-top": "15.5px",
"padding-bottom": "15.5px"
}
},
"googleFonts": [
"Lato"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Lato, sans-serif",
"background-color": "#a1d2e6",
":hover": {
"background-color": "#91bdcf"
},
":focus": {
"background-color": "#91bdcf"
},
"font-weight": "bold"
},
"count": {
"font-size": "15px"
}
},
"googleFonts": [
"Lato"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
}
}
});
});
}
})();
/*]]>*/
display: block;
margin: 0 auto;
对我有用,甚至在你的代码笔中。