javascript - 将 Shopify 购买按钮样式设置为 100% 宽度
问题描述
自 2 年以来,我一直在我的网上商店使用 Shopifys Buy Button 。到目前为止效果很好,我想出了如何将购买按钮本身设置为(我的设计中需要它)。width: 100%
现在我添加/启用了options
Buy Button 的下拉菜单product
,以显示产品的变体。对于选项下拉菜单,我还需要一个width: 100%
.
问题:您是否认为,有一种解决方案可以将选项下拉菜单的样式也设置为width: 100%
?不删除 iFrame?(因为我对其余的样式很满意)对于购买按钮没问题,但我无法设置选项下拉菜单的样式...
你有什么建议吗?
干杯,尼尔斯
<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>
解决方案
推荐阅读
- c# - 基于单选按钮选择验证文本框
- laravel - 尝试在 AWS EC2 中托管 laravel 5.7 应用程序
- html - 如何使图像适合其 div CSS
- excel - 如果两列中的值匹配,则将第三列中的值插入第四列
- python - 如何使用 Python 纠正“'int' object is not iterable”错误?
- postgresql - 我可以相信 postgresql 中的每个更新语句都是原子的吗?
- javascript - 用户通过 cognito 身份验证后,如何通过用户凭据访问 s3 存储桶?
- kubernetes - 完整的 Kubernetes YAML 规范在哪里?
- firebase - firebase 云消息传递是否允许将推送通知定位到特定设备/用户等
- awk - Awk program creating very large negative number when trying to add up values from csv file