I found this post How to create sliding DIV on click?
But all the answers are Jquery methods. Is there any way to create this with PURE CSS? I have a couple other things in mind as well...
- What can I add to make the slide down div stay put when scrolling
- Change the link that triggers the animation to "Close" in order to make the div slide back up
Here is a link to the example in that post// http://shutterbugtheme.tumblr.com/
I've also tried googling but the only results are jquery methods...
You can recognize a 'focus' event on an element and act upon it using a CSS transition.
Here's an example which will move a div 50px down when clicked
Markup
CSS
Working example: http://jsfiddle.net/NBHeJ/
Easy:
Working example: https://jsfiddle.net/webarthur/3ep33h5s/
Another way to do the same thing:
Working example: https://jsfiddle.net/webarthur/3ep33h5s/1/
This can be done using the
target
pseudo class to detect the click.Set the button href to the id of the sliding div.
The slide down can then be done by setting the height of the sliding div on the slidingDiv :target class using a css3
transition
on the height.I don't think there's a way for the original button to change its href to close the sliding div using pure css, however you could always add a close button on the sliding div to close it.
This close button works by adding the same transition on the sliding div class.
Here is a WORKING DEMO.
Enjoy.
This is a good example of how to get started. You can see at the bottom, they post the source for the animate function they use, although this is javascript.
sliding-js-generic
If you want pure css, I'd use ws3schools has been excellent resource for many years, though be aware that a lot depends on browser support as to whether the effect you want will work or not.
w3schools-css
Basic structure to make the effect they have, you just need to work along the lines of two divs within the body, at the top hidden and the container visible, and run the animation of the hidden div to display pushing the other div down, keeping them both inline.
Run This Code.