Using just CSS3, is there a way to add a nice fade-in and slide-from-left transition effect on a DETAILS
/SUMMARY
reveal?
For a demo of this new tag, see this demo:
https://jsfiddle.net/43m61yt0/1/
Here's the HTML for it:
<details>
<summary>Copyright 1999-2014.</summary>
<section>
<p> - by Refsnes Data. All Rights Reserved.</p>
<p>All content and graphics on this web site are the property of the company Refsnes Data.</p>
</section>
</details>
In my case, after the summary
tag, I put all other content in its own section
tag so that I could style it because summary:after
selector didn't seem to work. I tried using CSS3 transitions on height for the section
and details
tag, but it didn't help. Here's what I tried:
<style type="text/css">
DETAILS
{
transition:height 3s ease-in;
}
</style>
You probably would want to use a CSS animation using the
keyframes
if you don't plan on having it appear when you hover over it. If you only want the animation to appear, say, when you see details/summary description on the page, you could use some jQuery so that the browser adds the class of the animation when scrolling.https://jsfiddle.net/22e95bxt/
Is this what you're looking for?
Edit: Whoops. This is NOT what you're asking for. My bad!
This should fix it.
Some credit goes to Andrew for pointing this out. I adapted his answer. Here's how this works. By adding the
[open]
attribute on theDETAILS
tag, it only fires the animation keyframe when clicked. Then, by addingSUMMARY ~ *
it means "all elements after theSUMMARY
tag" so that the animation applies to those, and not theSUMMARY
element as well.I recommend you also check out Animate.css here: http://daneden.me/animate. If