Dealing with hover on mobile

Sdílet
Vložit
  • čas přidán 29. 08. 2024

Komentáře • 137

  • @pureretro5979
    @pureretro5979 Před 2 lety +70

    This is good to know. I've used JavaScript in the past to add a class to the body for touch devices which then activate CSS styles for those users. This is a lot cleaner and appears to have good browser coverage too.

  • @Thebiggestgordon
    @Thebiggestgordon Před 2 lety +39

    Kevin you actually read my mind. I'm currently working on a therapy Web app that needs to be mobile responsive, and I was wondering the best way to replace hover animations if the user has a touchscreen. I literally couldn't do anything without this channel.

  • @FlameRat_YehLon
    @FlameRat_YehLon Před 2 lety +79

    But anyway, personally I'd say using hover to display any useful information should be considered bad design. It's easy to trigger (or disengage) by accident and also doesn't always available. Just show the information or always ask for a click/touch to trigger. The only valid use should really be just to indicate you are pointing at a clickable element and nothing more.

    • @profesor08
      @profesor08 Před 2 lety +6

      perfect point

    • @krazymeanie
      @krazymeanie Před 2 lety +3

      While thats true, for some its not aesthetically pleasing. You can still go the "bad design" route just with the indication that the object can be hovered, for example using arrow icons etc to indulge interaction. You just gotta make things clear enough so the user understand what the ui does and how to use it. Think of it as bad design done well.

    • @FlameRat_YehLon
      @FlameRat_YehLon Před 2 lety +4

      @@krazymeanie Personally never loved hover-over design even in the early 2000s, before iPhone made surfing Internet web page with touch screen popular. It was always, hey you are 1 px off the hover zone so we have to get rid of the whole thing for you.
      That was the era when animated objects can only be done in Javascript (rather than the GPU-accelerated CSS) so hover is either overly sensitive or very unresponsive.

    • @TesterAnimal1
      @TesterAnimal1 Před rokem

      That’s overly prescriptive.
      You then just deny extra functionality to users who happen to use a mouse.

    • @elissitdesign
      @elissitdesign Před rokem

      My whole website is hidden by a rollover. Guess I need a redesign.

  • @universecode1101
    @universecode1101 Před 2 lety +23

    I love pure css … Great Kevin 🤩✌🏻

  • @Victor_Marius
    @Victor_Marius Před 2 lety +8

    Another solution for touch devices and hover is to make it clear that there's some hidden content by adding an after element with an arrow (or arrows) symbol hinting it is an accordion.

  • @Brunoenribeiro
    @Brunoenribeiro Před 2 lety +8

    Just food for thought:
    Maybe intersectionObserver can give us a somewhat replacement for hover on small screens?
    On larger screens, you can see more elements at the same time, so hover is good to indicate where the user's attention is
    On smaller screens, the user usually sees just one element: the present one.
    So maybe we can do "hover" animations when the element appears on the screen
    What do you guys think?
    (disclaimer: it's a little off-topic. I know that devices with large screens can also have touch screens that doesn't support hover)

    • @nikilragav
      @nikilragav Před 2 lety

      Are you suggesting something like use intersection observer to only show the details of the card in the middle of the screen or something like that?

    • @Brunoenribeiro
      @Brunoenribeiro Před 2 lety

      @@nikilragav yep

  • @LePhenixGD
    @LePhenixGD Před 6 měsíci +1

    Amazing video Kevin!
    I really believe you should make a video about all the different types of media queries

  • @clevermissfox
    @clevermissfox Před 10 měsíci +1

    This is very very neat. Never realized there is a media query for touch devices

  • @lucasmarcinkiewicz2403
    @lucasmarcinkiewicz2403 Před 2 lety +1

    Kev, a very nice & easy way to solve problems with hover state. It def helps poeple to achieve a prompt resolution I agree, but sometimes what I'm also doing for a fancy effect is wrapping everything within an instance of intersection observer. When I'm scrolling the page then triggering a focus state for visible and centered elements (chosen selectors not everyone). This keeps all my animations working nice and effective.

  • @its.arjun.s
    @its.arjun.s Před 2 lety +1

    I never even knew about hover media query. Thanks!

  • @guestofallah7661
    @guestofallah7661 Před 2 lety

    I really was wondering how this can be done, I thought media query would be enough but since u mentioned touch desktop this makes more sense ,
    Thank u Kevin!

  • @user-23dfgnbk
    @user-23dfgnbk Před 4 měsíci

    That was exactly what I was looking for! Thank you for the video!

  • @itsPenguinBoy
    @itsPenguinBoy Před 2 lety +1

    Great solution... I thought I had a catch-all fix where the elements were display:none until their parent had focus-within. I enjoyed the experience on a touch device of tapping once to reveal and once to click... But that sucks because display:none removes it for screen readers too... I didn't think I could use visibility:hidden or opacity:0 because they're clickable but maybe a transform on the hidden element is the way to go.
    Of course if my hacks fail I will resort to your more appropriate advice!

  • @gomitchell
    @gomitchell Před 2 lety

    Thanks Kevin for this incredibly important and helpful lesson. I found that on my Mac Command + Alt/Option + M toggled the mobile view on Firefox.

  • @ed1nh0
    @ed1nh0 Před 2 lety +9

    Great! This should be included in our CSS-best-practices-guide and it head us to progressive enhancement or gracefull degradation. Either way it's a semantic behavior that we all want for our projects. Thank you Kevin!

  • @segovia102
    @segovia102 Před rokem

    Tried this with React using styled components. Using hover:hover and hover:none appeared to work fine in Chrome on a PC with developer tools. However, when I viewed the app on my A71 phone, it was not behaving correctly. I had to use pointer:fine and pointer: coarse and this worked perfectly. Cheers!

  • @crim-son
    @crim-son Před 2 lety

    This is just so mind blowing, learning new and very important things on this channel

  • @cgfit5182
    @cgfit5182 Před 2 lety

    ❤ i like this implementation. You nailed it! I will use this for my future request or projects. This channel is on 🔥.

  • @e11world
    @e11world Před 2 lety

    Did not even know about this. Thank you Kevin. Awesome as always!

  • @FvsJ101
    @FvsJ101 Před 2 lety

    Thank you Mr Powell 🙏 currently working on a project and I needed this!!! Legend.. 😎

  • @Anth-ony
    @Anth-ony Před 2 lety

    I just add 'ontouchstart' inside my opening body field ex: as a means to deal with this. This way, if a user touches anywhere on the screen where a hover effect may occur, it still happens. Same as if they're over a section and start to scroll with their finger, it'll fire off the hover effect. I find that this is how I personally would use a site so it works for me.

  • @bukkorossu
    @bukkorossu Před 2 lety

    Some new and cool stuff... once again. Gonna use it in my projects now. Thanks a lot!

  • @user-km9vl9ck9u
    @user-km9vl9ck9u Před 2 lety

    awesome stuff again!! thanks!

  • @hernanlara4659
    @hernanlara4659 Před 2 lety

    It is a good solution, although it would be highly interactive to get people to access the detail of the information by tapping, and go to the URL with the second tap

  • @Wynorrific1
    @Wynorrific1 Před 10 měsíci

    Youuuuuu areeeeee the greatest, I sayyyyyyty it again you’re the greatest. You shaped me into a great front end designer thank you sooooooooo much

  • @_g4m3r_
    @_g4m3r_ Před 2 lety +1

    So the most effective approach is to start with mobile dimensions and no hover effects, then scale it up to full size adding the fancy stuff we want in "@media hover: hover". Correct?

  • @dansnel
    @dansnel Před 9 měsíci

    It can be done responsive if some custom properties are set from js when (and after) the DOM is loaded. So, title may be multiple line text, as you know. I think it's time for you to introduce and use web components. Only way for complete solutions. Sync of web comp is last part of definitely frameworks removing. Let's say Lit is a compromise, maybe angular for webapp, maybe electron for native desktop app. But client side should become independent 100%.

  • @FuzailShaikh
    @FuzailShaikh Před 2 lety

    Thanks mate! Keep making such videos

  • @CriminalClinton
    @CriminalClinton Před 2 lety

    Earned a sub! Don’t let me down. Keep up the consumable content 👍

  • @khodok2061
    @khodok2061 Před 2 lety

    So I'm still a student, but I've made a few websites and I am one of those people who actually love the language...
    A few months ago I moved from Firefox to Vivaldi (Chromium)
    And this video taught me that media queries could do more than just affect screens and sizes... so that's cool.
    but it also taught me where to find the touch no touch thing on Chrome... and that, I had given up on searching
    So thanks Kevin 😂

  • @kostiantynkarzhanov9216

    Awesome! Kevin, thank you so much! 💛

  • @Drivingralle
    @Drivingralle Před 2 lety

    Such a great CSS feature

  • @jorgecortez7448
    @jorgecortez7448 Před 2 lety

    My God, this is bonkers thanks for sharing!

  • @originalbinaryhustler3876

    Much appreciated ❤

  • @benlow24
    @benlow24 Před 2 lety

    Super helpful media query. I was wondering how to do this when building/designing SaaS apps.

  • @ivanmitov4920
    @ivanmitov4920 Před 3 měsíci

    Super usefull! Thanks!

  • @rjtkoh
    @rjtkoh Před rokem

    thanks, very well explained

  • @CuervoAmarillo
    @CuervoAmarillo Před 10 měsíci

    Thanks a lot Kevin, you never disappoint!

  • @desitoonswala
    @desitoonswala Před 2 lety +8

    Kevin can make fully functional website with css without using html and java 😂😂

  • @DTunezOfficial
    @DTunezOfficial Před 2 lety

    Hover: hover doesnt work if your browser supports long press to hover. It does work in the inspector but on a real device it ignores it (I have a OnePlus 8 Pro with Chrome and it still uses the hover:hover query). Pointer: coarse is better because this does work

  • @luckylukeskywalker
    @luckylukeskywalker Před 2 lety

    Exactly what i was looking up a few weeks ago:)

  • @rrd_webmania
    @rrd_webmania Před 2 lety

    Yes, yes! A mobile CSS video. Thanks

  • @prateek5019
    @prateek5019 Před 2 lety

    Always helpful and insightful. 🤘

  • @MJ_the_Gamer
    @MJ_the_Gamer Před 2 lety +1

    Do a css series course videos

  • @ibrahimdelice9422
    @ibrahimdelice9422 Před 2 lety

    Wow this is amazing. Thank you!

  • @borisnieminen677
    @borisnieminen677 Před rokem

    thanks, excellent tutorial.

  • @jhoannyosuna6483
    @jhoannyosuna6483 Před 2 lety

    you're the best! thank you

  • @islamibrahim8121
    @islamibrahim8121 Před 2 lety

    Noticed that Kevin's wearing a dftba t-shirt! I'm a nerdfighter too!!

  • @mrjebbar
    @mrjebbar Před 2 lety

    You the man bro, you're too epic at styling

  • @joejoe04
    @joejoe04 Před 2 lety

    Super helpful and useful, thanks!

  • @x-Mick-x
    @x-Mick-x Před rokem

    KP you are my go to for css videos and I'm wondering how an elements title attribute works on a touch screen, or how you could make them work.

  • @zackaryhall8593
    @zackaryhall8593 Před 2 lety

    Thank you for this!

  • @TobiSGD
    @TobiSGD Před 2 lety

    Thank you, this really solves some problems for me.

  • @blazi_0
    @blazi_0 Před 2 lety

    He just knows what I'm searching for this guy is a wizard

  • @user-kj7bn8ls3b
    @user-kj7bn8ls3b Před 2 lety

    Many thanks for your video)

  • @sujoydutta920
    @sujoydutta920 Před 2 lety

    I already love CSS 🥰 nice to know this new trick

  • @wahabkazmi7486
    @wahabkazmi7486 Před 2 lety

    Just did it in very bad approach using is in my last project! I wish I knew it earlier

  • @franktielemans6624
    @franktielemans6624 Před 2 lety

    I learned something today.

  • @sherwancaris5199
    @sherwancaris5199 Před 2 lety

    This is why we call you: The King 👑 of CSS!

  • @uthsarakawmini9793
    @uthsarakawmini9793 Před 6 měsíci

    its really heapfull. thanks

  • @TheBorninmotion
    @TheBorninmotion Před 2 lety

    wow its very useful thank you Kevin !

  • @bigjenny7954
    @bigjenny7954 Před 6 měsíci

    excellent!

  • @excelemma5960
    @excelemma5960 Před 2 lety

    Kelvin🤲🏾❤️ always happy once i see your videos

  • @ropoxdev
    @ropoxdev Před 2 lety

    We love you Kevin ❤️❤️❤️

  • @terryg4415
    @terryg4415 Před 2 lety

    Awesome!

  • @Yenlui76
    @Yenlui76 Před 2 lety

    Cursor media query seems nice to condition the size of buttons

  • @udageethdias
    @udageethdias Před 2 lety

    hey kevin can you pls make a video of css animation.transition,transform,translate css properties cause i dont i have any knowledge about all that at all.This will very helpful.

  • @SolomonMathai
    @SolomonMathai Před 2 měsíci

    can u tell me how to add auto hover in media max width 576px . the hover i added is only working when i tap the item . i need my hover when it is at the centre of the mobile screen

  • @vinayc.annangi
    @vinayc.annangi Před 2 lety

    Also for hover on mobile dragging from left to right or vice versa should work.

  • @ajzack983
    @ajzack983 Před 2 lety

    Is there a way to use the same in-card animations maybe when the user touches the card while scrolling ? I THOUGHT THAT WOULD BE THE ALTERNATIVE FOR A HOVER

  • @kbzcomuy
    @kbzcomuy Před 7 měsíci

    muy bueno, gracias

  • @herion05
    @herion05 Před 2 lety

    Just a heads up that this media query doesnt work on most samsung devices. Weirdly enough they trigger the hover: hover query but not the hover: none. Until thats fixed I cant find this media query useful.

  • @sanmeetsingh4
    @sanmeetsingh4 Před 2 lety

    Super Awesome stuff 👍

  • @sahilmalhotra6464
    @sahilmalhotra6464 Před 11 hodinami

    Nice video

  • @LuisCarlosPando
    @LuisCarlosPando Před 2 lety

    I love your content Kevin, keep it up! 🫶

  • @conradgroenewald4605
    @conradgroenewald4605 Před 2 lety

    That is a very useful tip thanks.

  • @max_samusevich
    @max_samusevich Před 2 lety

    media hover and any-hover don't work in my Firefox 102. Does anyone have the same issue? Caniuse and MDN say it is supported by Firefox

  • @lesalmin
    @lesalmin Před 2 lety

    Thanks!

  • @undochlorine
    @undochlorine Před 2 lety

    thank u

  • @niteshbabu5731
    @niteshbabu5731 Před měsícem

    So instead of using screen sizes, can we just use these media queries to check if were on mobile?

  • @dbweb.creative
    @dbweb.creative Před 2 lety

    is there a way in css to do long touch press to then for example show title?..

  • @madhuroshan2083
    @madhuroshan2083 Před 2 lety

    Hey Kevin! Can you make a video on how to use a tag and styling it , its complete usage please😁😁

  • @oliver139
    @oliver139 Před 2 lety

    New knowledge!

  • @beinyourguard
    @beinyourguard Před 2 lety

    amazing!

  • @SaleKnezevic
    @SaleKnezevic Před 2 lety

    Wish I could have remember at least 20% of what I have seen in your videos...and even now it is awesome. Well done sir, like always.

  • @FilippoDanieleLegname
    @FilippoDanieleLegname Před 2 lety

    Grazie.

  • @chrisbailey1173
    @chrisbailey1173 Před 2 lety

    I've been using pointer fine in my media queries for my hover effects. Would you recommend using hover hover instead?

  • @waseksamin3216
    @waseksamin3216 Před 2 lety

    This is soo cool

  • @misssincere5762
    @misssincere5762 Před 2 lety

    I wondered about this.

  • @raoufbakhti7786
    @raoufbakhti7786 Před rokem

    hi i have small problem when id did what you said it works for chome mobile (chrom mobile toch mode )but it didnt on my android phone use kast version of chrome do you have help ?

  • @kalebakeitshokile1366

    god I love this dude

  • @stansimi7500
    @stansimi7500 Před rokem

    Does anyone have this kind example card with responsive mansory design or similar? thx

  • @ShehabElDabaa
    @ShehabElDabaa Před rokem

    greeeeeeeeeeeeat, you made my day

  • @xbxb
    @xbxb Před 2 lety

    I thought the solution is when it scroll to that card the info will show with animations.

  • @osawereao
    @osawereao Před 2 lety

    Okay, I can honestly say I respect @Kelvin so much that it is love. He is just an awesome human being from my perspective

  • @leonard_9500
    @leonard_9500 Před 2 lety

    I fondly remember how you could hover on the Samsung Galaxy S4.

  • @vightibor8907
    @vightibor8907 Před 2 lety

    I often wonder whilst watching to your videos: "This should not be free"

  • @spencebuzz9220
    @spencebuzz9220 Před 2 lety

    This kinda makes pages a bit bland on mobile. I'd rather give myself an aneurysm by fiddling with JS to have it function properly even on mobile Safari.

  • @carlom43
    @carlom43 Před 2 lety

    Great video!
    I have a project and I need to fill a hover object with data from a table.
    I want a user to hover over a name of a company and the website outputs data from a table, as that data is subject to updates
    Can I do this with CSS or do I need to know Java too. Where do I start

  • @kasetophono
    @kasetophono Před 2 lety

    My mind is genuinely blown