Skip to content

Instantly share code, notes, and snippets.

@yun77op
Created August 31, 2016 03:36
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 yun77op/1b3b51f9ccb5eedd386370748d8c5c97 to your computer and use it in GitHub Desktop.
Save yun77op/1b3b51f9ccb5eedd386370748d8c5c97 to your computer and use it in GitHub Desktop.
css containment layout
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>css containment</title>
<style>
body {
padding: 30px;
}
#animate {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
border-radius: 50%;
background: red;
transition: transform 2s 0s;
will-change: transform;
}
</style>
<button onclick="moveIt()">moveIt</button>
</head>
<body>
<h1>css containment</h1>
<div id="animate_wrap" style="contain:layout; overflow:hidden; position:relative;width:100px;height:200px;">
<div id="animate"></div>
</div>
<script>
function moveIt() {
document.getElementById('animate').style.top = '10px';
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment