Lowtherpress Posted March 20, 2023 Share Posted March 20, 2023 I am building a site for client that has an animation on the landing page which plays on hover, but I would like it to play automatically on mobile. I tried adding media queries to my css for the animation, but when I did the animation just disappeared. The site is: https://apricots-glockenspiel-bp3w.squarespace.com password: hjz. The code I used is: @media screen only and (min-width: 951px) {#block-yui_3_17_2_1_1677692883512_13151 {background-image: url("https://static1.squarespace.com/static/639deed3983f0a5c484c8891/t/63ffa436d602ff11286533c3/1677698110235/Untitled_Artwork+29.png"); background-size: cover; }} @media screen only and (min-width: 951px) {#block-yui_3_17_2_1_1677692883512_13151:hover { background-image: url("https://static1.squarespace.com/static/639deed3983f0a5c484c8891/t/6407ad3c0a922d6651a42ca5/1678224755080/Untitled_Artwork+4+copy.gif"); }} @media screen only and (max-width: 640px) {#block-yui_3_17_2_1_1677692883512_13151 {background-image: url(https://static1.squarespace.com/static/639deed3983f0a5c484c8891/t/6407ad3c0a922d6651a42ca5/1678224755080/Untitled_Artwork+4+copy.gif); background-size: cover; }} Thank you! Link to comment
tuanphan Posted March 25, 2023 Share Posted March 25, 2023 You mean Desktop: Hover image >> play animation Mobile: Play animation automatically Is that right? 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
Lowtherpress Posted March 27, 2023 Author Share Posted March 27, 2023 On 3/24/2023 at 11:23 PM, tuanphan said: You mean Desktop: Hover image >> play animation Mobile: Play animation automatically Is that right? Yes, that's right Link to comment
tuanphan Posted April 2, 2023 Share Posted April 2, 2023 On 3/28/2023 at 2:11 AM, Lowtherpress said: Yes, that's right You can add a static image, when hover, we can use code to change to gif, and set gif appear first on mobile What do you think? 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
Lowtherpress Posted April 6, 2023 Author Share Posted April 6, 2023 On 4/2/2023 at 6:24 AM, tuanphan said: You can add a static image, when hover, we can use code to change to gif, and set gif appear first on mobile What do you think? Yes, that's how I have it on desktop – there is a static image and then a gif plays on hover. How would I code it so that gif plays automatically on mobile only? Link to comment
Solution tuanphan Posted April 8, 2023 Solution Share Posted April 8, 2023 On 4/7/2023 at 2:36 AM, Lowtherpress said: Yes, that's how I have it on desktop – there is a static image and then a gif plays on hover. How would I code it so that gif plays automatically on mobile only? Don't remove your code. Add this CSS for mobile @media screen and (max-width:767px) { div#block-yui_3_17_2_1_1677692883512_13151 img { content: url("https://static1.squarespace.com/static/639deed3983f0a5c484c8891/t/6407ad3c0a922d6651a42ca5/1678224755080/Untitled_Artwork+4+copy.gif"); } } 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
Lowtherpress Posted April 14, 2023 Author Share Posted April 14, 2023 On 4/8/2023 at 5:16 AM, tuanphan said: Don't remove your code. Add this CSS for mobile @media screen and (max-width:767px) { div#block-yui_3_17_2_1_1677692883512_13151 img { content: url("https://static1.squarespace.com/static/639deed3983f0a5c484c8891/t/6407ad3c0a922d6651a42ca5/1678224755080/Untitled_Artwork+4+copy.gif"); } } Worked! Thank you so much! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment