코드랩 레퍼런스

Layer Popup - Quick Scale Up 본문

SAMPLE

Layer Popup - Quick Scale Up

webstoryboy 2018.02.01 22:02

See the Pen layer Popup Style2 by Webstoryboy (@webstoryboy) on CodePen.

숨겨져 있던 레이어 팝업이 밑에서 위로 커지면서 나오는 애니메이션 레이어 팝업입니다.
<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<title>Layer Popup</title>
	<style>
		body {background: #7986cb; margin:0;}
		a {text-decoration: none; color:#666;}

		/* btn */
		.btn-wrap {
			display: flex; justify-content : center; 
			align-items : center; 
			height: 100vh;
		}
		.btn-wrap > a {
			background-color:#fff; 
			display:inline-block; 
			color: rgba(0,0,0,0.7); 
			padding: 13px 20px; 
			box-shadow: 0 2px 5px rgba(0,0,0,0.26); 
			height:23px; line-height: 23px; margin:5px; 
			border-radius: 3px;
		}
		/* modal */
		#modal {
			position: fixed; left:0; top:0; 
			width: 100%; height: 100%; 
			transform: scale(0); 
		}
		#modal .modal-bg {
			background: rgba(0,0,0,0.7); 
			display:flex; 
			align-items: center; 
			justify-content: center; 
			height: 100%; 
		}
		#modal .modal-bg .modal-cont {
			position:relative; 
			background: #fff; 
			padding: 40px; 
			max-width: 500px; 
			display: inline-block;
		}
		#modal .modal-bg .modal-cont h2 {
			font-size: 30px; 
			margin:0;
		}
		#modal .modal-bg .modal-cont p {
			font-size: 18px; 
		}
		#modal .modal-bg .modal-cont .close {
			position: absolute; top: 0; right:0; 
			margin:20px; padding: 10px; 
			background: #000; 
			border-radius: 50%; 
		}
		#modal .modal-bg .modal-cont .close svg {
			width: 24px; 
			fill: #fff; 
			vertical-align: top;
		}
		#modal.three {
			transform: scale(1);
		}
		#modal.three .modal-bg {
			background: rgba(0,0,0,0);
			animation: fadeIn 0.5s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.three .modal-bg .modal-cont {
			opacity: 0;
			animation: scaleUp 0.5s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.three.out {
			animation: quickScaleDown 0s .5s linear forwards;
		}
		#modal.three.out .modal-bg {
			background: rgba(0,0,0,0);
			animation: fadeOut 0.5s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.three.out .modal-bg .modal-cont {
			opacity: 0;
			animation: scaleDown 0.5s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}

		@keyframes fadeIn {
			0% {background: rgba(0,0,0,0)}
			100% {background: rgba(0,0,0,0.7)}
		}
		@keyframes fadeOut {
			0% {background: rgba(0,0,0,0.7)}
			100% {background: rgba(0,0,0,0)}
		}
		@keyframes scaleUp {
			0% {transform: scale(0.5) translatey(1000px); opacity:0}
			100% {transform: scale(1) translatey(0px); opacity:1}
		}
		@keyframes scaleDown {
			0% {transform: scale(1) translatey(0px); opacity:1}
			100% {transform: scale(0.5) translatey(1000px); opacity:0}
		}
		@keyframes quickScaleDown {
			0% {transform: scale(1);}
			99.9% {transform: scale(1); }
			100% {transform: scale(0); }
		}
	</style>
</head>
<body>
	<div class="btn-wrap">
		<a href="#" class="btn">Popup</a>
	</div>

	<div id="modal">
	    <div class="modal-bg">
	        <div class="modal-cont">
	            <h2>Layer Popup</h2>
	            <p>We hope you have enjoyed using Materialize and if you feel like it has helped you out and want to support the team you can help us by donating or backing us on Patreon. Any amount would help support and continue development on this project and is greatly appreciated.</p>
	            <a href="#" class="close close1">
	               <svg viewBox="0 0 24 24">
	                  <path d="M14.1,12L22,4.1c0.6-0.6,0.6-1.5,0-2.1c-0.6-0.6-1.5-0.6-2.1,0L12,9.9L4.1,2C3.5,1.4,2.5,1.4,2,2C1.4,2.5,1.4,3.5,2,4.1 L9.9,12L2,19.9c-0.6,0.6-0.6,1.5,0,2.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4l7.9-7.9l7.9,7.9c0.3,0.3,0.7,0.4,1.1,0.4 s0.8-0.1,1.1-0.4c0.6-0.6,0.6-1.5,0-2.1L14.1,12z"/>
						</svg>
	            </a>
	        </div>
	    </div>
	</div>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
	<script type="text/javascript">
		$(".btn").click(function(){
		    $("#modal").removeAttr("class").addClass("three");
		});

		$(".close").click(function(){
		    $("#modal").addClass("out");
		});
	</script>
</body>
</html>


Share

Ad

Comments
댓글쓰기 폼