Jump to content

HELP: Custom Button Not Turning Black on Hover - Being Overridden by Grey

Go to solution Solved by Web_Solutions,

Recommended Posts

👋 Hey Everyone,

I'm currently facing a peculiar issue with a button on my "My Experience" page. When the button is hovered over, it turns dark grey instead of solid black as intended. My suspicion is that something in the Squarespace default code or theme settings is overriding my custom CSS or JavaScript.

Would anyone be able to take a look and help me out? Below is the relevant code:
 

---------------------
CSS:
---------------------

/* Button Hover Styles */
.sqs-block-button-element--medium:hover,
.sqs-button-element--primary:hover,
.sqs-block-button-element:hover {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border: none !important;
}


---------------------
JavaScript:
---------------------

<script>
document.addEventListener('DOMContentLoaded', (event) => {
  console.log('Document is ready.');
  
  let buttons = document.querySelectorAll('.sqs-block-button-element, .button.sqs-system-button.sqs-editable-button.sqs-button-element--primary.FecjBqAV0ViY3ijU58R1, .newsletter-form-button.sqs-system-button.sqs-editable-button-layout.sqs-editable-button-style.sqs-editable-button-shape.sqs-button-element--primary, .btn.btn--border.theme-btn--primary-inverse.sqs-button-element--primary');
  
  console.log('Buttons found: ', buttons.length);
  
  buttons.forEach(button => {
    console.log('Adding animation to button', button);
    button.style.transition = 'transform 0.3s ease-in-out'; // Add smooth transition for transform only
    
    button.addEventListener('mouseover', function(){
      this.style.transform = 'scale(1.06)';
    });
  
    button.addEventListener('mouseout', function(){
      this.style.transform = 'scale(1.0)';
    });
  });
});
</script>

 

I've already tried a few different methods to troubleshoot, including inspecting the element, modifying the `!important` attribute, and adding additional console logs, but haven't had any luck. Any guidance or insight would be much appreciated!

Thanks in advance! 🙏

My Website URL: dinosaur-trombone-43wa.squarespace.com

Edited by mindofalexander
Link to comment
  • mindofalexander changed the title to HELP: Custom Button Not Turning Black on Hover - Being Overridden by Grey
  • Solution
Just now, mindofalexander said:

Bump!

 

Replace the CSS code with the code below.

/* Button Hover Styles */
.sqs-block-button-element--medium:hover,
.sqs-button-element--primary:hover,
.sqs-block-button-element:hover {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border: none !important;
  opacity: 1 !important;
}

 

Screenshot_159.png

If my comments are useful, please like and mark my solution as answer. It will encourage me. Thanks

MD Rofik
Website Designer and Digital Marketer

Am I helpful? Want to offer me a coffee?
Send me a message if needed any help. I'll try to reply as soon as possible.


 

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.