Is there a way to make this perfect example slide up instead of pushing the 'navs' down?
Currently, it reveals from top to bottom (pushing the menu down), but I want it to slide up and push the navs up when clicked.
The fiddle provided is very close to what I am looking for; however, I want the content to slide up to reveal.
I tried this code but it didn't work:
.animate({scrollTop: $('.dropdown').offset().top}, 250);
Do I need to adjust CSS positioning as well? I am still learning jQuery so any guidance would be appreciated.
UPDATE**
Here is an example of what I am aiming for:
The challenge is implementing the functionality demonstrated in the first fiddle where it has dual functions.
- When div 1 is clicked, it slides up to reveal content in section 2
- Clicking div 2 subsequently displays its content in the same section as div 1
- Clicking div 2 again should slide down to hide that section
And vice versa for div 1 and div 2.
Update 2**
I have made progress! See the updated fiddle here:
The only remaining issue is getting the black menu to push up to create a revealing effect. Would adjusting the CSS fixed positioning help with this? Changing it to relative seems to disrupt the animation.
I came across a website (DeanCare) that achieves this effect elegantly, but their code is complex and outdated. My goal is to simplify the code while achieving the same sliding effect.
Update 3**
This is the closest I've gotten, but it's still not quite right: