Стиль Shopify Купить кнопку до 100% ширины - PullRequest
0 голосов
/ 31 марта 2020

Я работаю с Shopifys Кнопка покупки в моем интернет-магазине уже 2 года. До сих пор это работало хорошо, и я понял, как установить саму кнопку покупки на width: 100% (она мне нужна в моем дизайне).

Теперь я добавил / включил выпадающее меню options для кнопки Купить product, чтобы показать варианты продукта. Для выпадающего меню опций мне также понадобится width: 100%.

Вопрос: Как вы думаете, есть ли решение для стилизации выпадающего списка опций также до width: 100%? Без удаления iFrame? (Потому что я доволен остальным стилем) Для кнопки «Купить» это не было проблемой, но я не могу стилизовать выпадающий список опций ...

Моя ссылка на кодовый указатель

Есть ли у вас какие-либо предложения?

Есть похожая тема.

Ура, 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>

1 Ответ

0 голосов
/ 31 марта 2020

Добавьте следующее под options.product.styles:

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

Проверьте это Пример JSFiddle .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...