Skip to content

Instantly share code, notes, and snippets.

@msweeney
Created October 21, 2010 07:49
Show Gist options
  • Save msweeney/638079 to your computer and use it in GitHub Desktop.
Save msweeney/638079 to your computer and use it in GitHub Desktop.
the height doesn't transition unless set prior (chrome 6, safari 5)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
#demo {
overflow: hidden;
}
.fix {
height: 1.2em;
}
.hidden {
-webkit-transition-property: height;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: ease-out;
height: 0;
}
</style>
</head>
<body>
<p>this is some text above</p>
<div id="demo">check it out!!</div>
<p>this is some text below</p>
<button id="test">test code</button>
<button id="fix">fix height</button>
<script>
var tester = document.getElementById('test'),
fixer = document.getElementById('fix'),
node = document.getElementById('demo');
tester.onclick = function() {
node.className += ' hidden'; // append so it maintains fix
};
fixer.onclick = function() {
node.className = 'fix';
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment