Max-height transition

Size
2,643 Kb
Views
4,048

How do I make an max-height transition?

Quick demo showing how to animate the height of selected containers.. What is a max-height transition? How do you make a max-height transition? This script and codes were developed by António Capelo on 15 December 2022, Thursday.

Max-height transition Previews

Max-height transition - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>max-height transition</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="main-container"> <h1 class="title">Show stuff</h1> <input type="checkbox" data-text="opt1"/> Option #1 <input type="checkbox" data-text="opt2"/> Option #2 <div class="extra-stuff-container hide" id="opt1"> <div class="extra-stuff"> some text </div> </div> <div class="extra-stuff-container hide" id="opt2"> <div class="extra-stuff opt2"> even more text </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Max-height transition - Script Codes CSS Codes

html { height: 100%;
}
input { margin-bottom: 20px;
}
body { height: 100%; font-family: Arial; background: url(https://subtlepatterns.com/patterns/stardust.png);
}
.main-container { width: 500px; border-radius: 4px; padding: 10px; background: #D6D6D6; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);
}
.main-container .title { margin: 0; padding: 10px;
}
.main-container .extra-stuff-container { background: url(https://subtlepatterns.com/patterns/stardust.png); color: ghostwhite; max-height: 100px; overflow: hidden; -webkit-transition: all 0.8s ease-out; transition: all 0.8s ease-out;
}
.main-container .extra-stuff-container .extra-stuff { padding: 10px;
}
.main-container .extra-stuff-container.hide { max-height: 0px;
}

Max-height transition - Script Codes JS Codes

window.onload = function () { var check1, check2; check1 = $('#opt1'); $('input').on('change', function(e) { var text = $(this).data('text'); console.log(text); if (text) { $(this).is(":checked") ? $('#'+text).removeClass('hide') : $('#'+text).addClass('hide') ; } })
}
Max-height transition - Script Codes
Max-height transition - Script Codes
Home Page Home
Developer António Capelo
Username capelo
Uploaded December 15, 2022
Rating 3
Size 2,643 Kb
Views 4,048
Do you need developer help for Max-height transition?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

António Capelo (capelo) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!