Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created January 26, 2024 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/63d021a02c04819be81b92e598296b58 to your computer and use it in GitHub Desktop.
Save ziadoz/63d021a02c04819be81b92e598296b58 to your computer and use it in GitHub Desktop.
HTML/CSS/JS Transition Height Slide
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
<!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