Search code examples
htmljquerycssmediasticky

Hey, I need to fix/sticky a div in desktop version only. Not in Mobile version. So Please suggest me how to stick a div


enter image description hereI need to fix/sticky a div in desktop version only. Not in Mobile version. Basically I have an ecommerce website in single product page I want to fix add to cart part sticky and people scroll but that area will not disappear and that part is always scroll by user scrolling you can see images. You can go by using this link https://letronne.com/products/example-product?variant=34631988379799


Solution

  • The solution depends on how you want to detect mobile devices, easy solution could be @media with a specifc Screen resolution an setting Position:fixed if it matches.
    A more stable solution would be to determine the user agent and setting the position:fixed via js/jQuery. Take a look Here: What is the best way to detect a mobile device?