Jump to content

Solution for sticky hover issue on mobile screens

Recommended Posts

Posted

site: https://www.amethystwallgallery.com/

pass: Help123!

The target for this solve is the "Add To Cart" button found in any product item in the store.

I am trying to have a :hover effect only on the desktop version of my site, and an :active effect on the mobile version of my site, without using pixel breakpoints. With my limited experience with CSS, I have tried a couple of things such as:

Quote

@media (hover: hover) {
     .button:hover {
          opacity:0.5;
          transition: opacity 150ms ease-in-out
          }}
@media (hover: none) {
     .button:active {
          opacity:0.5;
          transition: opacity 150ms ease-in-out
          }}
.button {
     opacity:1;
     transition: opacity 150ms ease-in-out
     }

I have also tried without a media query:

Quote

.button:hover, .button:active {
     opacity:0.5;
     transition: opacity 150ms ease-in-out
     }
.button {
     opacity:1;
     transition: opacity 150ms ease-in-out
     }

In both cases, the button functions as intended on desktop but I still get sticky hover on mobile. I have reached my knowledge limit with CSS, please enlighten me!

  • Replies 4
  • Views 986
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted
4 hours ago, amethystwallgallery said:

site: https://www.amethystwallgallery.com/

pass: Help123!

The target for this solve is the "Add To Cart" button found in any product item in the store.

I am trying to have a :hover effect only on the desktop version of my site, and an :active effect on the mobile version of my site, without using pixel breakpoints. With my limited experience with CSS, I have tried a couple of things such as:

I have also tried without a media query:

In both cases, the button functions as intended on desktop but I still get sticky hover on mobile. I have reached my knowledge limit with CSS, please enlighten me!

On mobile, we do not have the action of hover, we only have the touch event to work around. So the code for hover will not work on mobile

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - PDF Lightbox popup - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> No-code customisations for Squarespace

Posted
10 minutes ago, Beyondspace said:

On mobile, we do not have the action of hover, we only have the touch event to work around. So the code for hover will not work on mobile

Yeah I am aware of this, maybe I haven't worded it right, I have autism so communication isn't my strong point   : /

Basically:

  • I'd like to have CSS code so that a :hover effect (to 0.5 opacity) that is limited only to hover-supported versions of my site
  • On devices where hover is NOT supported, I would like to have an :active effect (to 0.5 opacity) instead. Kind of like emulating the :hover effect of the desktop site, but just for the duration of a touch event, like when someone taps a screen.

Is this possible to code in?

Posted
11 minutes ago, amethystwallgallery said:

Yeah I am aware of this, maybe I haven't worded it right, I have autism so communication isn't my strong point   : /

Basically:

  • I'd like to have CSS code so that a :hover effect (to 0.5 opacity) that is limited only to hover-supported versions of my site
  • On devices where hover is NOT supported, I would like to have an :active effect (to 0.5 opacity) instead. Kind of like emulating the :hover effect of the desktop site, but just for the duration of a touch event, like when someone taps a screen.

Is this possible to code in?

- On desktop, i check that the opacity transition Css code when hovering is working now. Do you still need any other help?

- On mobile display, we need to implement javascript code, which is only available on Business Plan/ above ones, so with some code we can control the touch events

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - PDF Lightbox popup - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> No-code customisations for Squarespace

Posted
5 minutes ago, Beyondspace said:

- On desktop, i check that the opacity transition Css code when hovering is working now. Do you still need any other help?

- On mobile display, we need to implement javascript code, which is only available on Business Plan/ above ones, so with some code we can control the touch events

The hover works as intended on desktop, but still sticks on mobile even if I use @media (hover: hover)

I believe I have the basic commerce package so Javascript should be available to me, what code should I use? I am even more unfamiliar with Javascript.

If possible I would like a pure CSS fix but that is down to my desire to use just one code language, for no other reason than it would be very satisfying haha

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.