svg+css实现信封邮件鼠标悬停翻转打开信件圣诞节快乐祝福效果代码

代码语言:html

所属分类:悬停

代码描述:svg+css实现信封邮件鼠标悬停翻转打开信件圣诞节快乐祝福效果代码

代码标签: svg css 信封 邮件 鼠标 悬停 翻转 打开 信件 圣诞节 快乐 祝福

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
  
  
<style>
@import url(https://fonts.bunny.net/css?family=nothing-you-could-do:400);

*,
::before,
::after {
	box-sizing: border-box;
}
body {
	font-family: "Nothing You Could Do", handwriting;

	background: radial-gradient(#005f8f, #001f3f, black);
	color: #4a4a4a;
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	padding: 1rem;
}

.envelope {
	--duration: 1000ms;

	--shadow-width: calc(var(--envelope-width) * 0.85);
	--shadow-blur: 15px;

	--envelope-width: 300px;
	--envelope-height: 175px;
	--envelope-clr-bg: #d14d44;
	--envelope-clr-bg-side: #c24e46;
	--envelope-clr-bg-bottom: #e15349;
	--envelope-clr-bg-top: #d14d44;
	--envelope-clr-txt: #fff;

	/*--envelope-transform: rotateY(0deg);*/
	--envelope-transform-hover: rotateY(180deg);
	--evelope-rotate-delay: calc(var(--duration) / 1);
	--evelope-rotate-delay-hover: 0ms;

	--letter-clr-bg: #fff;
	--letter-clr-text: green;
	--letter-font-size: 1rem;
	--letter-delay: 0ms;
	--letter-delay-hover: calc(
		var(--duration) * 1.25
	); /* delay before revealing card */

	--letter-height: calc(var(--envelope-height) - 2rem);
	--letter-height-hover: calc(var(--envelope-height) * 1.75);

	--fold-rotate: rotateX(0deg);
	/*--fold-zindex: 10;*/
	--fold-zindex-hover: 0;
	--fold-rotate-hover: rotateX(180deg);
	--fold-delay: calc(var(--duration) / 2); /* delay before opening top section */
	--fold-delay-hover: calc(var(--duration) * .75);

	--front-font-size: 1rem;
	--snowman-width: 50px;
	--bells-width: 30px;

	position: relative;
	height: var(--envelope-height);
	width: var(--envelope-width);
	perspective: 1000px;
	cursor: pointer;
}

@media (min-width: 720px) {
	.envelope {
		--envelope-width: 600px;
		--envelope-height: 350px;
		--letter-font-size: 1.6rem;
		--snowman-width: 130px;
		--bells-width: 60px;
		--front-font-size: 1.25rem;
	}
}
/* shadow */
.envelope::after {
	content: "";
	position: absolute;
	top: 110%;
	left: 50%;
	width: var(--shadow-width);
	height: 40px;
	transition: var(--duration) ease-in-out;
	transition-delay: var(--evelope-rotate-delay);
	transform: var(--shadow-transform);
	translate: -50% 0;
	border-radius: 50%;
	background: rgba(56, 6, 6, 0.4);
	filter: blur(var(--shadow-blur));
}

.envelope:hover {
	--envelope-transform: var(--envelope-transform-hover, 0deg);
	--evelope-rotate-delay: var(--evelope-rotate-delay-hover);
	--shadow-transform: rotateY(180deg);
	--fold-rotate: var(--fold-rotate-hover);
	--fold-delay: var(--fold-delay-hover);
	--fold-zindex: var(--fold-zindex-hover);
	--letter-height: var(--letter-height-hover);
	--letter-delay: var(--letter-delay-hover);
}

.envelope-inner {
	position: relative;
	width: 100%;
	height: 100%;

	transition: var(--duration) ease-in-out;
	transition-delay: var(--evelope-rotate-delay);
	transform-style: preserve-3d;
	transform: var(--envelope-transform);
	display: grid;
}

.envelope-front,
.envelope-back {
	position: relative;
	grid-area: 1/1;
	width: 100%;
	height: 100%;
	background-color: var(--envelope-clr-bg);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	perspective: 1000px;
	isolation: isolate;
}

.envelope-front {
	color: var(--envelope-clr-txt);
	display: grid;
	place-content: center;
}
.envelope-front .postage-stamp {
	position: absolute;
	top: 1em;
	right: 0.5em;
	width: 15%;
}
.envelope-front .address {
	text-align: left;
	font-size: var(--front-font-size);
}
.envelope-front .address > p > span:first-child {
	font-family: system-ui;
	font-weight: 200;
}
.envelope-front .address > p > span:last-of-type {
	font-weight: 800;
}

.envelope-back {
	/* start with back rotated*/
	transform: rotateY(180deg);
}
/* back folds */
.envelope-back::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	background-image: conic-gradient(
		transparent 60deg,
		var(--envelope-clr-bg-side) 60deg 120deg,
		var(--envelope-clr-bg-bottom) 120deg 240deg,
		var(--envelope-clr-bg-side) 240deg 300deg,
		transparent 300deg
	);
}
/* top fold which folds up on hover */
.envelope-back .top-fold {
	position: absolute;
	inset: 0;
	z-index: var(--fold-zindex, 10);
	background-color: var(--envelope-clr-bg-top);
	clip-path: polygon(0% 0%, 50% 55%, 100% 0%);

	transform: var(--fold-rotate);
	transform-origin: top;
	transition: var(--duration) ease-in-out;
	transition-delay: var(--fold-delay);
}

.letter {
	position: absolute;
	bottom: 5px;
	left: 50%;
	width: 90%;
	height: var(--letter-height);
	font-size: var(--letter-font-size);
	transform: translateX(-50%);
	background: var(--letter-clr-bg);
	z-index: 2;
	padding: 2em 3em;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	align-items: center;
	text-align: center;
	transition: var(--duration) ease-in-out;
	transition-delay: var(--letter-delay);
	overflow: hidden;
}
.letter > svg.snowman {
	width: var(--snowman-width);
}
.letter svg.bells {
	width: var(--bells-width);
	color: orange;
}
.letter p {
	margin: 0;
	font-weight: bold;
	width: 32ch;
	color: var(--letter-clr-text);
}
</style>


  
  
</head>

<body translate="no">
  <div class="envelope">

	<div class="envelope-inner">

		<div class="envelope-front">

			<div class="postage-stamp ">
				<svg fill="currentColor" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 300 300" xml:space="preserve">
					<path d="M253.98,257.652c0-8.568,8.568-17.748,17.136-18.361c-1.224-4.895-1.224-10.402-0.611-15.299 c-3.061,0.611-7.345,0-10.404-1.225c-6.12-3.061-9.792-9.18-9.792-15.912c0-9.18,7.956-20.807,17.136-21.42 c0-2.447,0.612-4.896,0.612-7.344s0.612-4.896,0.612-7.344c-7.956,3.061-17.137-4.283-18.973-12.24 c-1.836-9.792,4.284-17.748,12.853-21.42c-0.612-1.836-0.612-4.284-0.612-6.12c0-3.672,0-7.344,0.612-11.016 c-3.061,0-6.12-1.224-9.181-3.06c-4.283-3.06-6.731-7.344-7.344-12.24c0-0.612,0-1.836,0-2.448c0-9.792,8.568-15.3,17.136-16.524 c-0.611-3.672,0-7.956,0-11.628c0-3.06,0-6.12,0.612-9.18c-7.956,2.448-18.36-4.284-20.808-12.24 c-2.448-7.956,1.836-17.748,9.792-20.808c-1.225-3.06-1.225-6.732-1.225-10.404c0-3.06-0.611-6.732-0.611-9.792 c-9.792,12.24-39.168,4.284-40.393-9.18C205.632,3.672,200.124,1.836,195.84,0c0.611,9.18-7.956,17.748-17.137,17.748 c-9.18,0-16.523-6.732-18.359-15.3c-2.448,0-4.896,0-6.732-0.612c-2.448,0-4.896-0.612-7.956-1.224c0,4.284-2.448,9.18-5.508,12.24 c-3.672,3.672-9.18,6.12-14.076,6.12c-1.224,0-2.448,0-3.672-0.612c-5.508-1.224-12.24-4.896-14.076-11.016 c0-0.612,0-0.612,0-1.224c-4.896,0.612-11.016-0.612-15.912-2.448c-0.612,8.568-9.18,15.3-18.36,14.076 c-4.284-0.612-9.792-3.06-11.016-7.344c0-0.612,0-0.612,0-1.224c0,0,0,0.612-0.612,0.612c-3.672,3.06-8.568,2.448-12.852,1.836 c-1.224,0-2.448,0-3.672,0c1.224,0.612,1.836,1.836,2.448,2.448c3.672,4.896,5.508,11.016,3.06,17.136 c-3.06,8.568-14.076,12.24-22.032,9.18c0,1.224-0.612,1.836-0.612,3.06c-0.612,3.672-0.612,6.732-0.612,10.404 c9.792-1.224,22.644,1.224,23.868,12.852c0.612,5.508-3.06,11.016-8.568,12.852c-2.448,1.224-5.508,1.224-7.956,1.224 c-0.612,0-1.224,0-2.448-0.612c0,1.836,0,4.284,0,6.12c0,3.672,0.612,7.344-0.612,11.016l0,0c0.612,0,0.612-0.612,1.224-0.612 c11.628-3.672,23.256,7.344,19.584,18.972c-1.224,4.896-5.508,8.568-9.792,10.404c-3.672,1.224-6.732,1.836-10.404,1.836 c-0.612,1.836-0.612,3.06-1.224,4.896c-0.612,2.448-0.612,5.508-0.612,7.956c8.568-4.284,22.032-1.836,22.644,9.18 c0.612,9.179-10.404,24.48-21.42,23.869c0,1.223,0,3.059,0,4.283c0,2.447-0.612,4.896-0.612,7.957 c2.448-1.225,6.12-1.836,9.18-1.836c6.12,0.611,11.016,4.895,12.24,11.016c3.672,13.463-9.18,22.643-20.808,20.807 c-0.612,4.285-1.224,9.793-1.836,13.465c5.508-4.283,17.748-3.061,21.42,4.283c8.568,15.912-8.568,25.705-22.032,28.152 c0,4.896,0,10.404-1.224,15.301c7.344-4.285,18.36-4.285,25.704,0c7.956,4.896,11.628,13.463,11.628,22.031 c3.672-0.611,7.344-1.223,11.016-1.223c0-8.568,9.18-20.197,16.524-20.809c4.896-0.613,9.792,2.447,11.628,7.344 c1.836,4.283,1.224,9.791,3.06,14.076c0.612,0,1.224-0.611,1.836-0.611c3.06,0,4.896-0.613,7.344-1.838 c-0.612-1.836,0-3.672,0.612-6.119c1.224-4.896,5.508-9.18,10.404-10.404c11.016-3.061,19.584,4.896,22.645,14.688 c3.672-0.611,7.344-0.611,11.628-0.611c1.836,0,3.672,0,5.508,0.611c-2.448-8.566,4.284-18.971,13.464-19.584 c0.612,0,1.224,0,1.836,0c5.508,0,10.404,3.061,13.464,6.732c1.836,2.449,3.672,5.508,4.284,8.568c1.224,0,2.448,0,4.284,0 s3.672,0,5.508,0c1.224-7.955,9.792-14.076,17.748-14.688c7.956-0.613,15.912,3.672,19.584,11.016 c5.508-3.672,13.464-6.119,20.808-6.119c0-2.449,0-4.896,0-7.957C261.936,273.564,253.98,264.996,253.98,257.652z M243.576,266.221 c0,4.283-6.12,4.283-6.12,0l0,0c-3.672-77.725-4.896-155.449-9.792-233.173c-0.611,0.612-1.224,0.612-2.447,0.612 c-52.633,0-105.264,1.836-157.896,1.836c0,0,0,0-0.612,0c6.732,15.3,3.06,41.616,3.06,57.528c0,17.748,0,35.496,0,53.856 c0,39.78,0,79.56-1.224,119.341c0,1.836-1.224,3.059-2.448,3.672c50.796-12.854,115.668-14.076,167.688-6.732 c1.836,0.611,3.061,1.836,3.061,3.672s-1.225,4.283-3.672,4.896c-15.912,0.611-31.824,0.611-47.736,0.611 c-12.852,0-25.704,0-39.168,0.611c-26.316,1.225-53.856,4.285-79.56,0.613c-1.836,0-1.836-3.061,0-3.672 c-2.448,1.223-6.732,0-6.12-3.672c1.224-76.5-1.836-154.225,3.06-230.725c0-2.448,0-4.896,0.612-7.344c0-3.06,4.284-3.06,4.284,0 c0,0.612,0,1.224,0,1.224c19.584-2.448,39.168-3.672,59.364-4.896c33.048-1.224,66.097-1.224,98.532-0.612 c1.224,0,2.448,0.612,3.06,1.22.........完整代码请登录后点击上方下载按钮下载查看

网友评论0