Hover settimeout
Is it possible to make a component scrollable(overflow:hidden to scroll) after 2seconds of hovering ? transition really doesnt work
24 Replies
not without javascript
it is animatable, so, you should be able to set an animation that has a 2s delay and a count of 1
transition-delay isn't applying to overflow in my testing
:hover triggers the scroll instantly, and other properties after a 2 second delay
https://codepen.io/jochemm/pen/zYyZxLa?editors=1100
I'd love to be proved wrong, I'm probably just missing something
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow <-- it's weird, because this says it should work
overflow - CSS: Cascading Style Sheets | MDN
The overflow CSS shorthand property sets the desired behavior when content does not fit in the parent element box (overflows) in the horizontal and/or vertical direction.
i can't get it to work either
i have an idea
I DID IT!!!!!!
so, the
9999px
is what makes it work
it sets the max-height as basically "big enough"
this is an hack, but it works
if you want "completely infinite", you can use 9999cm
instead
the max-height must be equal on bothEdit fiddle - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
ooh, so you fake animating the overflow by using a second div that has the overflow, clever!
and use a transition on that 2nd div
this could probably be faked with a
clip-path
but it's too much for my brainit's a pretty elegant solution like this, actually
i feel dirty using
9999cm
, but it works
however, if you have an element that's 9999cm high, you should stophaha, yeah, definitely
lets see what he does with this hacked hack
This change to your code works. The overflow can't be animated in the sense of gradual transition, but it does work as a sudden change. It's the same for something like display: none to display: block. That works as an instantaneous change instead of gradual.
i couldnt get that to work
for some reason
it works, but with a couple of caveats. It switches at 1 second (50%), and if you don't add
forwards
to the animation, it'll reset a bit laterI don't know what code you are trying. Here is a demo of Jochem's code with my modifcation. https://codepen.io/chooking/pen/WNLpvpd
I forgot about that.
very nice solution though!
So make it 4s forwards.
yup (with a comment for future you / colleagues)
alternatively, add 0%, 99%, and 100% keyframes with the first two at
overflow: hidden;
or, even better
that works
and you now only need the
100%
animation
this worked for me
but hey, this went from "it's impossible without javascript" to "here's a 9999cm div" to "here's the best version of it"collaboration for the win \o/
also shows why you shouldn't listen to a backend dev about CSS
it's me, I'm the backend dev
i am the everything dev