popcornnomad Posted October 6 Posted October 6 Site URL: https://mudramarketinggroup.com/ Hi! I hope someone can help me because I'm going bananas here... I need to add a secondary button that appears next to the main button on my product page, the problem is that I cannot figure out how to align them and with the same size. This is the code I've injected on the footer: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function() { // Move the button inside the add-to-cart button wrapper $('section.ProductItem-additional .button-block').appendTo('.ProductItem-details .sqs-add-to-cart-button-wrapper'); // Inject the CSS dynamically into the head section $('head').append(` <style> /* Wrapper for the buttons */ .ProductItem-details .sqs-add-to-cart-button-wrapper { display: flex; justify-content: space-between; /* Spread the buttons evenly */ gap: 5px; /* Space between buttons */ width: 50%; /* Ensure the container takes full width */ box-sizing: border-box; /* Ensure padding and border do not affect width */ } /* Style both buttons equally */ .ProductItem-details .sqs-add-to-cart-button-wrapper .button, .ProductItem-details .sqs-add-to-cart-button-wrapper .button-block { flex-grow: 1; /* Make both buttons take up the same amount of space */ text-align: center; /* Center the button text */ padding: 5px; /* Adjust padding for button size */ background-color: none; /* Adjust button background color */ color: white; /* Button text color */ border: none; /* Remove border */ border-radius: none; /* Add rounded corners */ box-sizing: border-box; /* Ensure padding doesn’t affect size */ transition: all 0.3s ease; /* Smooth transitions */ } /* Ensure shadow and size are consistent */ .ProductItem-details .sqs-add-to-cart-button-wrapper .button-block { box-shadow: none; /* Remove shadow if present */ } /* Hover effect (optional) */ .ProductItem-details .sqs-add-to-cart-button-wrapper .button:hover, .ProductItem-details .sqs-add-to-cart-button-wrapper .button-block:hover { background-color: none; /* Darken background on hover */ } /* Mobile adjustments */ @media screen and (max-width: 767px) { .ProductItem-details .sqs-add-to-cart-button-wrapper { flex-direction: column; /* Stack buttons vertically on mobile */ } .ProductItem-details .sqs-add-to-cart-button-wrapper .button, .ProductItem-details .sqs-add-to-cart-button-wrapper .button-block { width: 100%; /* Ensure buttons take full width on mobile */ } } </style> `); }); </script>
tuanphan Posted October 7 Posted October 7 Can you share link? I tried checking a product but don't see second button https://mudramarketinggroup.com/store/p/seo-guide-for-beginners Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
popcornnomad Posted October 9 Author Posted October 9 Hi Tuanhpan and thanks for replying to me so fast! Sorry I was trying to work on the content for the product page. I am new to coding and it's so hard to customise the product page as I want it. I also want to change the live demo button. Here is the link: https://mudramarketinggroup.com/store/p/951uov7mqi58da9vbgtwf0sape3ca0
tuanphan Posted October 11 Posted October 11 On 10/9/2024 at 11:16 AM, popcornnomad said: Hi Tuanhpan and thanks for replying to me so fast! Sorry I was trying to work on the content for the product page. I am new to coding and it's so hard to customise the product page as I want it. I also want to change the live demo button. Here is the link: https://mudramarketinggroup.com/store/p/951uov7mqi58da9vbgtwf0sape3ca0 First, to align text same line, you can use this code to Website Tools > Custom CSS div.sqs-add-to-cart-button { display: flex !important; align-items: center; justify-content: center; } to make both same height, use this CSS code div.ProductItem-quantity-add-to-cart .button-block { padding-top: 0px !important; padding-bottom: 0px !important; } Do you need to make both same width? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
popcornnomad Posted October 12 Author Posted October 12 Omg thanks so so much for your help! and yeah I would love to have them the same size 🙂
popcornnomad Posted October 15 Author Posted October 15 On 10/11/2024 at 1:43 PM, tuanphan said: First, to align text same line, you can use this code to Website Tools > Custom CSS div.sqs-add-to-cart-button { display: flex !important; align-items: center; justify-content: center; } to make both same height, use this CSS code div.ProductItem-quantity-add-to-cart .button-block { padding-top: 0px !important; padding-bottom: 0px !important; } Do you need to make both same width? Yes please! 🙂
Solution tuanphan Posted October 16 Solution Posted October 16 To make same width, use this CSS code div.sqs-add-to-cart-button, div.sqs-add-to-cart-button-wrapper .button-block { width: 50% !important; } div.sqs-add-to-cart-button-wrapper .button-block div, div.sqs-add-to-cart-button-wrapper .button-block a { width: 100% !important; display: block !important; } Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
popcornnomad Posted October 16 Author Posted October 16 On 10/11/2024 at 1:43 PM, tuanphan said: First, to align text same line, you can use this code to Website Tools > Custom CSS div.sqs-add-to-cart-button { display: flex !important; align-items: center; justify-content: center; } to make both same height, use this CSS code div.ProductItem-quantity-add-to-cart .button-block { padding-top: 0px !important; padding-bottom: 0px !important; } Do you need to make both same width? Thanks so so much for your help!
popcornnomad Posted October 25 Author Posted October 25 I've added a perfect aligned second button to my Product page. This page is my template page, but I need to duplicate it as I have multiple products. This live demo button needs to be directed to different URL's, is there any way I can do it, without duplicating the code injection on the footer for each product?
paul2009 Posted October 25 Posted October 25 1 hour ago, popcornnomad said: This live demo button needs to be directed to different URL's Instead of adding a script to the Code Injection Footer, it would be better to add it to a Code Block in the Product's Additional Info section. You can then customise the script for each Product Detail Page (PDP), adding an anchor tag with a custom href attribute dynamically. tuanphan 1 Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
popcornnomad Posted October 30 Author Posted October 30 Hi Paul! Thanks so much for your reply, yeah I don't know why I tried to complicate it so much now it works perfectly! Again thanks, sometimes you just need someone to take you out of your head... paul2009 and tuanphan 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment