Skip to content

Instantly share code, notes, and snippets.

@EduVencovsky
Created October 22, 2019 18:52
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 EduVencovsky/dc907abbefb01077e93be34849c5d7f8 to your computer and use it in GitHub Desktop.
Save EduVencovsky/dc907abbefb01077e93be34849c5d7f8 to your computer and use it in GitHub Desktop.
CSS Scale Transition
<button id="open">open</button>
<div class="box scale">
<h1>
hey
</h1>
</div>
// http://jsfiddle.net/decru76v/4/
var isOpen = false
$("#open").click(function(e){
var scale = isOpen ? 0 : 1
$(".scale")
.css('transform', `scale(${scale})`)
.css('top', this.offsetBottom)
.css('left', this.getBoundingClientRect().right)
isOpen = !isOpen
})
body{
margin-top:25px;
margin-left:25px;
}
.box{
width:100px;
height:100px;
background:red;
}
.scale{
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
transform-origin: left top;
transform: scale(0.0);
position: absolute;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment