将 Shopify Buy Button 样式设置为 100% 宽度
Style Shopify Buy Button to 100%width
我在 online shop 上使用 Shopifys 购买按钮 已经 2 年了。到目前为止效果很好,我想出了如何将购买按钮本身设置为 width: 100%
(我的设计中需要它)。
现在我 added/enabled Buy Button product
的 options
下拉菜单显示产品的变体。对于选项下拉菜单,我还需要一个 width: 100%
.
问题: 你认为有没有办法将选项下拉菜单的样式设置为 width: 100%
?不删除 iFrame? (因为我对其余的造型很满意)
对于 Buy Button 没问题,但我无法设置选项下拉菜单的样式...
你有什么建议吗?
There is a similar thread.
干杯,尼尔斯
<div id='product-component-1585569803212'></div>
<script type="text/javascript">
/*<![CDATA[*/
(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: 'bei-fuchs-hase.myshopify.com',
storefrontAccessToken: '6901072a2c2d3e1bf907bf2280b6bb08',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product', {
id: '4485325586480',
node: document.getElementById('product-component-1585569803212'),
moneyFormat: '%E2%82%AC%7B%7Bamount_with_comma_separator%7D%7D',
options: {
"product": {
"variantId": "8847592259628",
"width": "100%",
"contents": {
"img": false,
"imgWithCarousel": false,
"title": false,
"variantTitle": false,
"options": true,
"price": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"text": {
"button": "In den Korb"
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px",
}
},
"button": {
"background-color": "00000",
"font-family": "Source Sans Pro, sans-serif",
"font-size": "16px",
"padding-left": "46px",
"padding-right": "46px",
"padding-top": "17px",
"padding-bottom": "16px",
"margin-right": "8px",
"width": "100%",
":hover": {"background-color": "#ff5d33"
},
"border-radius": "0px",
"font-weight": "normal",
"letter-spacing": "1px",
":focus": {
"background-color": "#000000"
}
},
"variantTitle": {
"font-family": "Source Sans Pro, sans-serif",
"color": "#000000",
"font-weight": "normal"
},
"title": {
"font-family": "Source Sans Pro, sans-serif",
"font-size": "26px",
"color": "#000000"
},
"description": {
"color": "#000000",
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Source Sans Pro, sans-serif",
"font-size": "18px",
"color": "#000000",
"font-weight": "normal"
},
"compareAt": {
"font-size": "15px",
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal",
"color": "#000000"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro"
]
},
"cart": {
"popup":false,
"contents": {
"button": true
},
"text": {
"title": "WARENKORB",
"total": "Zwischensumme",
"notice": "Versand- und Rabattcodes werden beim Checkout hinzugefügt.",
"empty": "Dein Warenkorb ist leer."
},
"styles": {
"button": {
"background-color": "#000000",
"font-family": "Source Sans Pro, sans-serif",
":hover": {
"background-color": "#000000"
},
"border-radius": "0px",
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
},
"title": {
"color": "#000000"
},
"footer": {
"background-color": "#ffffff"
},
"header": {
"color": "#000000"
},
"lineItems": {
"color": "#000000"
},
"subtotalText": {
"color": "#000000"
},
"subtotal": {
"color": "#000000"
},
"notice": {
"color": "#000000"
},
"currency": {
"color": "#000000"
},
"close": {
":hover": {
"color": "#000000"
},
"color": "#000000"
},
"emptyCart": {
"color": "#000000"
}
},
"googleFonts": [
"Source Sans Pro"
]
},
"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": "#000000",
"font-family": "Source Sans Pro, sans-serif",
"padding-left": "30px",
"padding-right": "30px",
":hover": {
"background-color": "#000000"
},
"border-radius": "0px",
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
},
"variantTitle": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"title": {
"font-family": "Source Sans Pro, sans-serif"
},
"description": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"compareAt": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Source Sans Pro, sans-serif",
"background-color": "#000000",
":hover": {
"background-color": "#000000"
},
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
}
},
"googleFonts": [
"Source Sans Pro"
]
},
"option": {
"styles": {
"label": {
"font-family": "Source Sans Pro, sans-serif"
},
"wrapper": {
"max-width": "none",
"width": "100%",
},
"select": {
"font-family": "Source Sans Pro, sans-serif"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
},
"lineItem": {
"styles": {
"variantTitle": {
"color": "#000000"
},
"title": {
"color": "#000000"
},
"price": {
"color": "#000000"
},
"quantity": {
"color": "#000000"
},
"quantityIncrement": {
"color": "#000000",
"border-color": "#000000"
},
"quantityDecrement": {
"color": "#000000",
"border-color": "#000000"
},
"quantityInput": {
"color": "#000000",
"border-color": "#000000"
}
}
}
}
});
});
}
})();
/*]]>*/
</script>
在options.product.styles
下添加以下内容:
"options": {
"max-width": "100% !important"
}
检查此 JSFiddle example。
我在 online shop 上使用 Shopifys 购买按钮 已经 2 年了。到目前为止效果很好,我想出了如何将购买按钮本身设置为 width: 100%
(我的设计中需要它)。
现在我 added/enabled Buy Button product
的 options
下拉菜单显示产品的变体。对于选项下拉菜单,我还需要一个 width: 100%
.
问题: 你认为有没有办法将选项下拉菜单的样式设置为 width: 100%
?不删除 iFrame? (因为我对其余的造型很满意)
对于 Buy Button 没问题,但我无法设置选项下拉菜单的样式...
你有什么建议吗?
There is a similar thread.
干杯,尼尔斯
<div id='product-component-1585569803212'></div>
<script type="text/javascript">
/*<![CDATA[*/
(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: 'bei-fuchs-hase.myshopify.com',
storefrontAccessToken: '6901072a2c2d3e1bf907bf2280b6bb08',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product', {
id: '4485325586480',
node: document.getElementById('product-component-1585569803212'),
moneyFormat: '%E2%82%AC%7B%7Bamount_with_comma_separator%7D%7D',
options: {
"product": {
"variantId": "8847592259628",
"width": "100%",
"contents": {
"img": false,
"imgWithCarousel": false,
"title": false,
"variantTitle": false,
"options": true,
"price": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"text": {
"button": "In den Korb"
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px",
}
},
"button": {
"background-color": "00000",
"font-family": "Source Sans Pro, sans-serif",
"font-size": "16px",
"padding-left": "46px",
"padding-right": "46px",
"padding-top": "17px",
"padding-bottom": "16px",
"margin-right": "8px",
"width": "100%",
":hover": {"background-color": "#ff5d33"
},
"border-radius": "0px",
"font-weight": "normal",
"letter-spacing": "1px",
":focus": {
"background-color": "#000000"
}
},
"variantTitle": {
"font-family": "Source Sans Pro, sans-serif",
"color": "#000000",
"font-weight": "normal"
},
"title": {
"font-family": "Source Sans Pro, sans-serif",
"font-size": "26px",
"color": "#000000"
},
"description": {
"color": "#000000",
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Source Sans Pro, sans-serif",
"font-size": "18px",
"color": "#000000",
"font-weight": "normal"
},
"compareAt": {
"font-size": "15px",
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal",
"color": "#000000"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro"
]
},
"cart": {
"popup":false,
"contents": {
"button": true
},
"text": {
"title": "WARENKORB",
"total": "Zwischensumme",
"notice": "Versand- und Rabattcodes werden beim Checkout hinzugefügt.",
"empty": "Dein Warenkorb ist leer."
},
"styles": {
"button": {
"background-color": "#000000",
"font-family": "Source Sans Pro, sans-serif",
":hover": {
"background-color": "#000000"
},
"border-radius": "0px",
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
},
"title": {
"color": "#000000"
},
"footer": {
"background-color": "#ffffff"
},
"header": {
"color": "#000000"
},
"lineItems": {
"color": "#000000"
},
"subtotalText": {
"color": "#000000"
},
"subtotal": {
"color": "#000000"
},
"notice": {
"color": "#000000"
},
"currency": {
"color": "#000000"
},
"close": {
":hover": {
"color": "#000000"
},
"color": "#000000"
},
"emptyCart": {
"color": "#000000"
}
},
"googleFonts": [
"Source Sans Pro"
]
},
"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": "#000000",
"font-family": "Source Sans Pro, sans-serif",
"padding-left": "30px",
"padding-right": "30px",
":hover": {
"background-color": "#000000"
},
"border-radius": "0px",
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
},
"variantTitle": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"title": {
"font-family": "Source Sans Pro, sans-serif"
},
"description": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
},
"compareAt": {
"font-family": "Source Sans Pro, sans-serif",
"font-weight": "normal"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro",
"Source Sans Pro"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Source Sans Pro, sans-serif",
"background-color": "#000000",
":hover": {
"background-color": "#000000"
},
"font-weight": "bold",
":focus": {
"background-color": "#000000"
}
}
},
"googleFonts": [
"Source Sans Pro"
]
},
"option": {
"styles": {
"label": {
"font-family": "Source Sans Pro, sans-serif"
},
"wrapper": {
"max-width": "none",
"width": "100%",
},
"select": {
"font-family": "Source Sans Pro, sans-serif"
}
},
"googleFonts": [
"Source Sans Pro",
"Source Sans Pro"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
},
"lineItem": {
"styles": {
"variantTitle": {
"color": "#000000"
},
"title": {
"color": "#000000"
},
"price": {
"color": "#000000"
},
"quantity": {
"color": "#000000"
},
"quantityIncrement": {
"color": "#000000",
"border-color": "#000000"
},
"quantityDecrement": {
"color": "#000000",
"border-color": "#000000"
},
"quantityInput": {
"color": "#000000",
"border-color": "#000000"
}
}
}
}
});
});
}
})();
/*]]>*/
</script>
在options.product.styles
下添加以下内容:
"options": {
"max-width": "100% !important"
}
检查此 JSFiddle example。