Jump to content

Center Add to Cart and change CSS colour of buttom padding etc

Recommended Posts

Site URL: https://enchantanddelight.com.au/

Code I'm using for shop page 

 

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK" crossorigin="anonymous"></script>
<script>
  $(".products .grid-item").each(function(e) {
      $(this).append('<div class="sqs-add-to-cart-button sqs-suppress-edit-mode sqs-button-element--primary" role="button" tabindex="0" data-product-type="1" data-original-label="Add To Cart"><div class="sqs-add-to-cart-button-inner">Add To Cart</div></div>');
  });
  $(function() {
    $(".products .grid-item").each(function(e){
      var dataItemId = $(this).attr('data-item-id');
      $(this).find('.sqs-add-to-cart-button').attr('data-item-id', dataItemId);
    });
  });
</script>

i'd like to add style code to it so it displays a bit nicer 

 

if you refer to the image the button alignment is off and i would also like to margin it a few spaces down so isn't directly under font? 

 

can anyone please help me with my code styling

 

20221008_170413.jpg

Link to comment
  • Replies 9
  • Views 371
  • Created
  • Last Reply

Top Posters In This Topic

18 hours ago, christina_marie_333 said:

Site URL: https://enchantanddelight.com.au/

Code I'm using for shop page 

 

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK" crossorigin="anonymous"></script>
<script>
  $(".products .grid-item").each(function(e) {
      $(this).append('<div class="sqs-add-to-cart-button sqs-suppress-edit-mode sqs-button-element--primary" role="button" tabindex="0" data-product-type="1" data-original-label="Add To Cart"><div class="sqs-add-to-cart-button-inner">Add To Cart</div></div>');
  });
  $(function() {
    $(".products .grid-item").each(function(e){
      var dataItemId = $(this).attr('data-item-id');
      $(this).find('.sqs-add-to-cart-button').attr('data-item-id', dataItemId);
    });
  });
</script>

i'd like to add style code to it so it displays a bit nicer 

 

if you refer to the image the button alignment is off and i would also like to margin it a few spaces down so isn't directly under font? 

 

can anyone please help me with my code styling

 

20221008_170413.jpg

Use the following Css code

.products-list .grid-item{
  display: flex;
  flex-direction: column;
  align-items: center;
}

.products-list .sqs-add-to-cart-button {
  background: orange !important; 
}

Support me by pressing 👍 if this useful for you

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

My testing

image.thumb.png.db5d3c3a451bce82e7d5aa1f2eb8d0e7.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Thank you Bangank36 i have added the css to the site. but is it possible to get the add to cart buttons to have smaller padding so the add to cart button is a bit thinner? 

Also would it be possible to get the add to cart button to sit a little lower so it isn't directly under the price. 

i appreciate  any of your help

These sections need a but of spacing and have you got a better idea on how I could make the sold-out text more visually appealing. 

Please help me with comment below as well @bangank36

 

 

20221011_104943.jpg

Edited by christina_marie_333
Link to comment

I can not see these buttons now.

Can you show them up?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Hey bangank6 I have added to a different site

www.spacept.com.au

www.spacept.com.au could you please help me with the same problem the buttons are to close to the price and the images of the products don't display in mobile view. 

I will need to apply to other site but applied it here because the code has bugs. would you be able to help me fix it. 

Edited by christina_marie_333
Link to comment
On 10/13/2022 at 8:41 AM, christina_marie_333 said:

Hey bangank6 I have added to a different site

www.spacept.com.au

www.spacept.com.au could you please help me with the same problem the buttons are to close to the price and the images of the products don't display in mobile view. 

I will need to apply to other site but applied it here because the code has bugs. would you be able to help me fix it. 

Don't remove any code in your current code.

Add to Design > Custom CSS

body.view-list div.sqs-add-to-cart-button {
    margin-top: 20px;
}
figure.grid-image {
    width: 100% !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!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.