js实现礼物打开下雪圣诞快乐动画效果代码

代码语言:html

所属分类:动画

代码描述:js实现礼物打开下雪圣诞快乐动画效果代码

代码标签: 打开 下雪 圣诞快乐 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en" class="no-js">

	<head>

		<meta charset="gb2312" />

		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<meta name="viewport" content="width=device-width, initial-scale=1.0">

		<title></title>

<style>
    
*, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }

body {
	background: #e74c3c;
	color: #fff;
	font-weight: 400;
	font-family: 'Lato', Calibri, Arial, sans-serif;
}

a {
	text-decoration: none;
	color: #fff;
	opacity: 0.7;
	outline: none;
}

a:hover, a:focus {
	opacity: 1;
	outline: none;
}

/* To Navigation Style */
.codrops-top {
	position: absolute;
	z-index: 200;
	top: 0;
	left: 0;
	width: 100%;
	text-transform: uppercase;
	font-size: 0.69em;
	line-height: 2.2;
	font-weight: 700;
}

.codrops-top a {
	display: inline-block;
	padding: 0 1em;
	text-decoration: none;
	letter-spacing: 0.1em;
}

.codrops-top span.right {
	float: right;
}

.codrops-top span.right a {
	display: block;
	float: left;
}

.codrops-icon:before {
	margin: 0 4px;
	text-transform: none;
	font-weight: normal;
	font-style: normal;
	font-variant: normal;
	font-family: 'codropsicons';
	line-height: 1;
	speak: none;
	-webkit-font-smoothing: antialiased;
}

.codrops-icon-drop:before {
	content: "\e001";
}

.codrops-icon-prev:before {
	content: "\e004";
}

@media screen and (max-width: 25em) {
	.codrops-top {
		font-size: 120%;
	}

	.codrops-icon span {
		display: none;
	}
}
html, body, .container {
	height: 100%;
}

body {
	background: #e74c3c url(//repo.bfw.wiki/bfwrepo/image/610a66b42577f.png) repeat-x bottom center;
	overflow: hidden;
}

h1 {
	position: absolute;
	bottom: 10px;
	right: 15px;
	color: #fff;
	font-family: 'Peralta', serif;
	text-transform: uppercase;
	font-size: 20px;
	margin: 0;
	font-weight: 400;
}

h1 span {
	display: block;
	-webkit-transform: skew(-20deg);
	transform: skew(-20deg);
}

.merrywrap {
	position: absolute;
	top: 40px;
	bottom: 40px;
	left: 40px;
	right: 40px;
}

.merrywrap svg path,
.merrywrap svg polygon,
.merrywrap svg circle {
	fill: none;
}

.giftbox {
	width: 300px;
	height: 220px;
	position: absolute;
	bottom: 0;
	left: 50%;
	margin-left: -150px;
	z-index: 10;
	cursor: pointer;
}

.giftbox::after {
	content: 'Click me';
	position: absolute;
	color: #fff;
	font-family: 'Peralta', serif;
	bottom: 0;
	left: 0;
	width: 100%;
	text-align: center;
	font-size: 24px;
	z-index: 1000;
	-webkit-transform: rotate(-20deg);
	transform: rotate(-20deg);
	-webkit-transform-origin: 0 0;
	transform-origin: 0 0;
}

.giftbox > div {
	background: #34495e;
	position: absolute;
}

.giftbox .cover {
	top: 0;
	left: 0;
	height: 25%;
	width: 100%;
	z-index: 2;
}

.giftbox .box {
	bottom: 0;
	height: 80%;
	left: 5%;
	right: 5%;
	z-index: 1;
}

.giftbox > div::after,
.giftbox > div::before {
	content: '';
	position: absolute;
	top: 0;
} 

/* ribbon */
.giftbox > div::before {
	background: #fdc56d;
	width: 50px;
	left: 50%;
	height: 100%;
	-webkit-transform: translateX(-50%);
	transform: translateX(-50%);
}

/* shadow */
.giftbox .box::after {
	background: rgba(0,0,0,0.1);
	left: 0;
	height: 30px;
	width: 100%;
}

.giftbox .cover div {
	position: absolute;
	height: 60px;
	width: 60px;
	bottom: 100%;
	left: 50%;
	margin-left: -30px;
}

.giftbox .cover div::before,
.giftbox .cover div::after {
	position: absolute;
	width: 100%;
	height: 100%;
	content: '';
	background: transparent;
	border-radius: 30px;
	box-shadow: inset 0 0 0 14px #fdc56d;
}

.giftbox .cover div::before {
	-webkit-transform: translateX(-45%) skewY(40deg);
	transform: translateX(-45%) skewY(40deg);
}

.giftbox .cover div::after {
	-webkit-transform: translateX(45%) skewY(-40deg);
	transform: translateX(45%) skewY(-40deg);
}

/* Grid */
.icons {
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	z-index: 1;
	position: absolute;
}

.icons .row {
	width: 100%;
	height: calc(100% / 7);
}

.icons span {
	display: block;
	float: left;
	width: calc((100% / 11) - 1px);
	height: 100%;
	font-family: 'Peralta';
	font-size: 74px;
	text-transform: uppercase;
	text-align: center;
	opacity: 0;
	-webkit-transition: -webkit-transform 0.5s ease-in, opacity 0.1s;
	transition: transform 0.5s ease-in, opacity 0.1s;
}

.icons span.letter {
	color: #fdc56d;
}

.icons svg path,
.icons svg polygon,
.icons svg circle {
	stroke: #fdc56d;
	stroke-width: 1;
}

/* Background */
.background {
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	opacity: 0;
}

.background svg path {
	stroke: #fdc56d;
	stroke-width: 0.8;
}

/* Grid elements transforms */
/* Step 1: All items in one point at the bottom */

/* First row */
.step-1 .icons .row:first-child span:first-child {
	-webkit-transform: translateY(700%) translateX(500%);
	transform: translateY(700%) translateX(500%);
}

.step-1 .icons .row:first-child span:nth-child(2) {
	-webkit-transform: translateY(700%) translateX(400%);
	transform: translateY(700%) translateX(400%);
}

.step-1 .icons .row:first-child span:nth-child(3) {
	-webkit-transform: translateY(700%) translateX(300%);
	transform: translateY(700%) translateX(300%);
}

.step-1 .icons .row:first-child span:nth-child(4) {
	-webkit-transform: translateY(700%) translateX(200%);
	transform: translateY(700%) translateX(200%);
}

.step-1 .icons .row:first-child span:nth-child(5) {
	-webkit-transform: translateY(700%) translateX(100%);
	transform: translateY(700%) translateX(100%);
}

.step-1 .icons .row:first-child span:nth-child(6) {
	-webkit-transform: translateY(700%) translateX(0);
	transform: translateY(700%) translateX(0);
}

.step-1 .icons .row:first-child span:nth-child(7) {
	-webkit-transform: translateY(700%) translateX(-100%);
	transform: translateY(700%) translateX(-100%);
}

.step-1 .icons .row:first-child span:nth-child(8) {
	-webkit-transform: translateY(700%) translateX(-200%);
	transform: translateY(700%) translateX(-200%);
}

.step-1 .icons .row:first-child span:nth-child(9) {
	-webkit-transform: translateY(700%) translateX(-300%);
	transform: translateY(700%) translateX(-300%);
}

.step-1 .icons .row:first-child span:nth-child(10) {
	-webkit-transform: translateY(700%) translateX(-400%);
	transform: translateY(700%) translateX(-400%);
}

.step-1 .icons .row:first-child span:nth-child(11) {
	-webkit-transform: translateY(700%) translateX(-500%);
	transform: translateY(700%) translateX(-500%);
}

/* Second row */
.step-1 .icons .row:nth-child(2) span:first-child {
	-webkit-transform: translateY(600%) translateX(500%);
	transform: translateY(600%) translateX(500%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(2) {
	-webkit-transform: translateY(600%) translateX(400%);
	transform: translateY(600%) translateX(400%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(3) {
	-webkit-transform: translateY(600%) translateX(300%);
	transform: translateY(600%) translateX(300%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(4) {
	-webkit-transform: translateY(600%) translateX(200%);
	transform: translateY(600%) translateX(200%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(5) {
	-webkit-transform: translateY(600%) translateX(100%);
	transform: translateY(600%) translateX(100%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(6) {
	-webkit-transform: translateY(600%) translateX(0);
	transform: translateY(600%) translateX(0);
}

.step-1 .icons .row:nth-child(2) span:nth-child(7) {
	-webkit-transform: translateY(600%) translateX(-100%);
	transform: translateY(600%) translateX(-100%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(8) {
	-webkit-transform: translateY(600%) translateX(-200%);
	transform: translateY(600%) translateX(-200%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(9) {
	-webkit-transform: translateY(600%) translateX(-300%);
	transform: translateY(600%) translateX(-300%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(10) {
	-webkit-transform: translateY(600%) translateX(-400%);
	transform: translateY(600%) translateX(-400%);
}

.step-1 .icons .row:nth-child(2) span:nth-child(11) {
	-webkit-transform: translateY(600%) translateX(-500%);
	transform: translateY(600%) translateX(-500%);
}

/* Third row */
.step-1 .icons .row:nth-child(3) span:first-child {
	-webkit-transform: translateY(500%) translateX(500%);
	transform: translateY(500%) translateX(500%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(2) {
	-webkit-transform: translateY(500%) translateX(400%);
	transform: translateY(500%) translateX(400%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(3) {
	-webkit-transform: translateY(500%) translateX(300%);
	transform: translateY(500%) translateX(300%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(4) {
	-webkit-transform: translateY(500%) translateX(200%);
	transform: translateY(500%) translateX(200%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(5) {
	-webkit-transform: translateY(500%) translateX(100%);
	transform: translateY(500%) translateX(100%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(6) {
	-webkit-transform: translateY(500%) translateX(0);
	transform: translateY(500%) translateX(0);
}

.step-1 .icons .row:nth-child(3) span:nth-child(7) {
	-webkit-transform: translateY(500%) translateX(-100%);
	transform: translateY(500%) translateX(-100%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(8) {
	-webkit-transform: translateY(500%) translateX(-200%);
	transform: translateY(500%) translateX(-200%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(9) {
	-webkit-transform: translateY(500%) translateX(-300%);
	transform: translateY(500%) translateX(-300%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(10) {
	-webkit-transform: translateY(500%) translateX(-400%);
	transform: translateY(500%) translateX(-400%);
}

.step-1 .icons .row:nth-child(3) span:nth-child(11) {
	-webkit-transform: translateY(500%) translateX(-500%);
	transform: translateY(500%) translateX(-500%);
}

/* Fourth row */
.step-1 .icons .row:nth-child(4) span:first-child {
	-webkit-transform: translateY(400%) translateX(500%);
	transform: translateY(400%) translateX(500%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(2) {
	-webkit-transform: translateY(400%) translateX(400%);
	transform: translateY(400%) translateX(400%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(3) {
	-webkit-transform: translateY(400%) translateX(300%);
	transform: translateY(400%) translateX(300%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(4) {
	-webkit-transform: translateY(400%) translateX(200%);
	transform: translateY(400%) translateX(200%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(5) {
	-webkit-transform: translateY(400%) translateX(100%);
	transform: translateY(400%) translateX(100%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(6) {
	-webkit-transform: translateY(400%) translateX(0);
	transform: translateY(400%) translateX(0);
}

.step-1 .icons .row:nth-child(4) span:nth-child(7) {
	-webkit-transform: translateY(400%) translateX(-100%);
	transform: translateY(400%) translateX(-100%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(8) {
	-webkit-transform: translateY(400%) translateX(-200%);
	transform: translateY(400%) translateX(-200%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(9) {
	-webkit-transform: translateY(400%) translateX(-300%);
	transform: translateY(400%) translateX(-300%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(10) {
	-webkit-transform: translateY(400%) translateX(-400%);
	transform: translateY(400%) translateX(-400%);
}

.step-1 .icons .row:nth-child(4) span:nth-child(11) {
	-webkit-transform: translateY(400%) translateX(-500%);
	transform: translateY(400%) translateX(-500%);
}

/* Fifth row */
.step-1 .icons .row:nth-child(5) span:first-child {
	-webkit-transform: translateY(300%) translateX(500%);
	transform: translateY(300%) translateX(500%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(2) {
	-webkit-transform: translateY(300%) translateX(400%);
	transform: translateY(300%) translateX(400%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(3) {
	-webkit-transform: translateY(300%) translateX(300%);
	transform: translateY(300%) translateX(300%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(4) {
	-webkit-transform: translateY(300%) translateX(200%);
	transform: translateY(300%) translateX(200%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(5) {
	-webkit-transform: translateY(300%) translateX(100%);
	transform: translateY(300%) translateX(100%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(6) {
	-webkit-transform: translateY(300%) translateX(0);
	transform: translateY(300%) translateX(0);
}

.step-1 .icons .row:nth-child(5) span:nth-child(7) {
	-webkit-transform: translateY(300%) translateX(-100%);
	transform: translateY(300%) translateX(-100%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(8) {
	-webkit-transform: translateY(300%) translateX(-200%);
	transform: translateY(300%) translateX(-200%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(9) {
	-webkit-transform: translateY(300%) translateX(-300%);
	transform: translateY(300%) translateX(-300%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(10) {
	-webkit-transform: translateY(300%) translateX(-400%);
	transform: translateY(300%) translateX(-400%);
}

.step-1 .icons .row:nth-child(5) span:nth-child(11) {
	-webkit-transform: translateY(300%) translateX(-500%);
	transform: translateY(300%) translateX(-500%);
}

/* Sixth row */
.step-1 .icons .row:nth-child(6) span:first-child {
	-webkit-transform: translateY(200%) translateX(500%);
	transform: translateY(200%) translateX(500%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(2) {
	-webkit-transform: translateY(200%) translateX(400%);
	transform: translateY(200%) translateX(400%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(3) {
	-webkit-transform: translateY(200%) translateX(300%);
	transform: translateY(200%) translateX(300%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(4) {
	-webkit-transform: translateY(200%) translateX(200%);
	transform: translateY(200%) translateX(200%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(5) {
	-webkit-transform: translateY(200%) translateX(100%);
	transform: translateY(200%) translateX(100%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(6) {
	-webkit-transform: translateY(200%) translateX(0);
	transform: translateY(200%) translateX(0);
}

.step-1 .icons .row:nth-child(6) span:nth-child(7) {
	-webkit-transform: translateY(200%) translateX(-100%);
	transform: translateY(200%) translateX(-100%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(8) {
	-webkit-transform: translateY(200%) translateX(-200%);
	transform: translateY(200%) translateX(-200%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(9) {
	-webkit-transform: translateY(200%) translateX(-300%);
	transform: translateY(200%) translateX(-300%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(10) {
	-webkit-transform: translateY(200%) translateX(-400%);
	transform: translateY(200%) translateX(-400%);
}

.step-1 .icons .row:nth-child(6) span:nth-child(11) {
	-webkit-transform: translateY(200%) translateX(-500%);
	transform: translateY(200%) translateX(-500%);
}

/* Seventh row */
.step-1 .icons .row:nth-child(7) span:first-child {
	-webkit-transform: translateY(100%) translateX(500%);
	transform: translateY(100%) translateX(500%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(2) {
	-webkit-transform: translateY(100%) translateX(400%);
	transform: translateY(100%) translateX(400%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(3) {
	-webkit-transform: translateY(100%) translateX(300%);
	transform: translateY(100%) translateX(300%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(4) {
	-webkit-transform: translateY(100%) translateX(200%);
	transform: translateY(100%) translateX(200%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(5) {
	-webkit-transform: translateY(100%) translateX(100%);
	transform: translateY(100%) translateX(100%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(6) {
	-webkit-transform: translateY(100%) translateX(0);
	transform: translateY(100%) translateX(0);
}

.step-1 .icons .row:nth-child(7) span:nth-child(7) {
	-webkit-transform: translateY(100%) translateX(-100%);
	transform: translateY(100%) translateX(-100%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(8) {
	-webkit-transform: translateY(100%) translateX(-200%);
	transform: translateY(100%) translateX(-200%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(9) {
	-webkit-transform: translateY(100%) translateX(-300%);
	transform: translateY(100%) translateX(-300%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(10) {
	-webkit-transform: translateY(100%) translateX(-400%);
	transform: translateY(100%) translateX(-400%);
}

.step-1 .icons .row:nth-child(7) span:nth-child(11) {
	-webkit-transform: translateY(100%) translateX(-500%);
	transform: translateY(100%) translateX(-500%);
}

/* Step 2 */

.step-2 .icons span {
	opacity: 1;
	-webkit-transition-timing-function: cubic-bezier(0.000, 0.000, 0.200, 0.910);
	transition-timing-function: cubic-bezier(0.000, 0.000, 0.200, 0.910);
}

.step-2 .icons .row:nth-child(2) span {
	-webkit-transition-delay: 0.1s;
	transition-delay: 0.1s;
}

.step-2 .icons .row:nth-child(3) span {
	-webkit-transition-delay: 0.15s;
	transition-delay: 0.15s;
}

.step-2 .icons .row:nth-child(4) span {
	-webkit-transition-delay: 0.2s;
	transition-delay: 0.2s;
}

.step-2 .icons .row:nth-child(5) span {
	-webkit-transition-delay: 0.25s;
	transition-delay: 0.25s;
}

.step-2 .icons .row:nth-child(6) span {
	-webkit-transition-delay: 0.3s;
	transition-delay: 0.3s;
}

.step-2 .icons .row:nth-child(7) span {
	-webkit-transition-delay: 0.35s;
	transition-delay: 0.35s;
}

/* First row */
.step-2 .icons .row:first-child span:first-child {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(2) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(3) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(4) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(5) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(6) {
	-webkit-transform: translateY(-300%) ;
	transform: translateY(-300%) ;
}

.step-2 .icons .row:first-child span:nth-child(7) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(8) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(9) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(10) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%);
}

.step-2 .icons .row:first-child span:nth-child(11) {
	-webkit-transform: translateY(-300%);
	transform: translateY(-300%.........完整代码请登录后点击上方下载按钮下载查看

网友评论0