Last active
August 29, 2015 14:07
-
-
Save mahiya/daa005be28d574f0cf04 to your computer and use it in GitHub Desktop.
jQueryに頼らないでWindowsストアライクなエレメント表示方法を実現する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title></title> | |
<style> | |
.item { | |
width: 100px; | |
height: 100px; | |
background-color: blue; | |
display: none; | |
} | |
.displaying { | |
-webkit-animation: show 1s cubic-bezier(0.165, 0.84, 0.44, 1); | |
position: relative; | |
display: block; | |
} | |
@-webkit-keyframes show { | |
0% { | |
opacity: 0; | |
left: 50px; | |
} | |
100% { | |
opacity: 1; | |
left: 0; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<button>show</button> | |
<div class="item"></div> | |
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
<script> | |
$(init); | |
function init() { | |
$("button").click(function () { | |
if ($(".item").hasClass("displaying")) { | |
$(".item").removeClass("displaying"); | |
} else { | |
$(".item").addClass("displaying"); | |
} | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment