Created
August 24, 2014 12:23
-
-
Save youcune/551f082b6cabe4f4ae5c to your computer and use it in GitHub Desktop.
CSS3 のみで display: none からフェードインさせる
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> | |
<head> | |
<meta charst='utf-8'> | |
<title>TEST</title> | |
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> | |
<style> | |
.box { | |
background: #000000; | |
display: none; | |
height: 240px; | |
opacity: 0; | |
width: 240px; | |
} | |
.visible.box { | |
display: block; | |
opacity: 1; | |
animation-duration: 0.5s; | |
animation-name: fade-in; | |
-moz-animation-duration: 0.5s; | |
-moz-animation-name: fade-in; | |
-webkit-animation-duration: 0.5s; | |
-webkit-animation-name: fade-in; | |
} | |
@keyframes fade-in { | |
0% { | |
display: none; | |
opacity: 0; | |
} | |
1% { | |
display: block; | |
opacity: 0; | |
} | |
100% { | |
display: block; | |
opacity: 1; | |
} | |
} | |
@-moz-keyframes fade-in { | |
0% { | |
display: none; | |
opacity: 0; | |
} | |
1% { | |
display: block; | |
opacity: 0; | |
} | |
100% { | |
display: block; | |
opacity: 1; | |
} | |
} | |
@-webkit-keyframes fade-in { | |
0% { | |
display: none; | |
opacity: 0; | |
} | |
1% { | |
display: block; | |
opacity: 0; | |
} | |
100% { | |
display: block; | |
opacity: 1; | |
} | |
} | |
</style> | |
<script> | |
$(function() { | |
$('#btn').click(function() { | |
$('.box').toggleClass('visible'); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class='container'> | |
<div class="box"></div> | |
<div> | |
<button id='btn'>START</button> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment