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:
details {
transition:height 3s ease-in;
}
<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.
For those looking for an open/close transition, it's possible to fake it by margin-bottom
property.
details {
background: gainsboro;
padding: 10px;
}
details summary {
cursor: pointer;
transition: margin 150ms ease-out;
}
details[open] summary {
margin-bottom: 10px;
}
<details>
<summary><code><details></code> pseudo content transition</summary>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quia amet magnam fugit nihil delectus, id ratione deleniti minima, ipsum accusantium exercitationem est ipsa, possimus harum distinctio consequatur qui recusandae et. Alias quas temporibus aliquam modi nulla omnis unde atque magni tempora, corporis ducimus voluptas, recusandae, repellendus officiis molestias cumque quam.
</details>