Created
January 26, 2024 17:46
-
-
Save ziadoz/63d021a02c04819be81b92e598296b58 to your computer and use it in GitHub Desktop.
HTML/CSS/JS Transition Height Slide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://jsfiddle.net/4hv8rcsd/ | |
https://keithjgrant.com/posts/2023/04/transitioning-to-height-auto/ | |
https://www.youtube.com/watch?v=B_n4YONte5A | |
https://chriscoyier.net/2022/12/21/things-css-could-still-use-heading-into-2023/#animate-to-auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style> | |
div.filters { | |
background: #999; | |
display: grid; | |
grid-template-rows: 0fr; | |
transition: grid-template-rows 0.5s ease-out; | |
} | |
div.filters.active { | |
grid-template-rows: 1fr; | |
} | |
div.filters > div { | |
overflow: hidden; | |
} | |
div.filters > div > div { | |
padding: 20px; | |
} | |
</style> | |
<script> | |
document.addEventListener('DOMContentLoaded', () => { | |
document.querySelector('a').addEventListener('click', (event) => { | |
event.preventDefault(); | |
document.querySelector('div.filters').classList.toggle('active'); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<a href="#">Filters</a> | |
<hr> | |
<div class="filters"> | |
<div> | |
<div> | |
<p>I am some filters.</p> | |
<label>Search: <input type="text"></label> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment