코드랩 레퍼런스

Layer Popup - Fold 본문

SAMPLE

Layer Popup - Fold

webstoryboy 2018.02.01 22:11

See the Pen layer Popup Style - fold by Webstoryboy (@webstoryboy) on CodePen.

숨겨져 있던 레이어 팝업이 펴져다가 접히는 레이어 팝업 애니메이션입니다.
<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<title>Layer Popup</title>
	<style>
		body {background: #64b5f6; 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; c
			olor: 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.one {
			transform: scaleY(0.01) scaleX(0);
			animation: unfoldIn 1s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.one .modal-bg .modal-cont {
			transform: scale(0);
			animation: zoomIn 0.5s 0.8s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.one.out {
			transform: scale(1);
			animation: unfoldOut 1s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		#modal.one.out .modal-bg .modal-cont {
			transform: scale(0);
			animation: zoomOut 0.5s cubic-bezier(0.165, 0.85, 0.44, 1) forwards;
		}
		@keyframes unfoldIn{
			0% {transform: scaleY(0.005) scaleX(0);}
			50% {transform: scaleY(0.005) scaleX(1);}
			100% {transform: scaleY(1) scaleX(1);}
		}
		@keyframes unfoldOut{
			0% {transform: scaleY(1) scaleX(1);}
			50% {transform: scaleY(0.005) scaleX(1);}
			100% {transform: scaleY(0.005) scaleX(0);}
		}
		@keyframes zoomIn {
			0% {transform: scale(0);}
			100% {transform: scale(1); }
		}
		@keyframes zoomOut {
			0% {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("one");
		});
		$(".close").click(function(){
		    $("#modal").addClass("out");
		});
	</script>
</body>
</html>


Share

Ad

Comments
댓글쓰기 폼