0

I´m working with Shopifys Buy Button on my online shop since 2 years. It worked well so far and I figured out how to set the buy button itself to width: 100% (I need it in my design).

Now I added/enabled the options dropdown menu for the Buy Button product, to show variants of the product. For the option dropdown menu I also need a width: 100%.

Question: Do you think, there is a solution to style the options dropdown also to width: 100%? Without removing the iFrame? (Because I'm happy with the rest of the styling) For the Buy Button it was no problem, but I can´t style the option dropdown...

My Codepen Link

Do you have any suggestions?

There is a similar thread.

Cheers, Nils

<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>
Nilson
  • 3
  • 1

1 Answers1

0

Add the following under the options.product.styles:

"options": {
  "max-width": "100% !important"
}

Check this JSFiddle example.

Vladimir
  • 2,461
  • 2
  • 14
  • 18