How can I make my primary nav dropdown slide down with an animation?
(JSFiddle for context: https://jsfiddle.net/25ghjzr0/4/)
I have a dropdown menu in my primary nav, which appears when you hover a link. I achieved this using display none to flex. I can't figure out how to animate it so that it goes from height 0% to height auto. The dropdown itself works but the links inside don't. Does anyone how how I can achieve this? Thanks
29 Replies
try this@Lord Of Insanity
Yeah this is what I'm looking for, I've been able to work it into my current nav and I've made it activate when you hover the "navIcon". Only problem with it is that when you do hover it you can see the dropdown grow in height and slide down into position. I'll upload a video of it.
I want it so that it starts to grow from the bottom of the actuation toggle, if that makes sense
bottom of about me?
Yeah
I might have figured it out. I removed the translate and put a transform-origin:top on the dropdown.
Also is there any way to make the js work with event listeners? I prefer using those to functions
i mean event listener is LITERALLY a function in js😂
Ah, I'm still kinda new to javascript so forgive me lol
i see, u used scaleY() here
that's why it looks a bit odd
I'd rather say, since u r using scaleY() also add opacity : 0
for the text inside
so the text fades out as well, that way it'll look less out dated
naah naah.. don't worry
the basic structure of eventListener
u can see at the end I used js as well
Yeah I have used them for my mobile nav, it's just it never occurred to me that they themselves are functions. I guess thats why some of my other code didn't work, I was trying to put a function inside the event listener
u can out function inside a function
it's most likely the way u did it is wrong
The only thing about this drop down that I'm not entirely fond of is that the text gets sorta squished when it folds back up, but I guess I can live with that
u can do it like this as well,
that's the reason why I said it looks add😂
and that's why i said, prolly try making it's opacity go down
that way it'll look less odd
at least a bit
Yeah that does help
make it relative to the nav?
oh sry I didn't see the second video
noice
So is there any way to make it so the links in the dropdown not scale and instead stay in the position they will be when the dropdown is open?
you would need to layer it, animate the bg and sublinks separate. Anything inside the scale is going to scale
so u r Saying, the texts will stay the same, but they'll appear only when the drop down opens
??
Yeah, although I don't think it matters that much on second thoughts
@Lord Of Insanity i so i think I've found a better way to do transition
or perhaps this
fot this
for this
Hi, I managed to compact my JS using event listeners, but it looks like I've broken some of it in the process. The dropdown no longer stays open when you hover over the links, except the first one. Here's a Jsfiddle for it: https://jsfiddle.net/ge5zfovu/1/. Do you know how I can fix this?
Edit fiddle - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.