七夕来袭,是时候展现专属于程序员的浪漫了- 跳动的心和摇晃的红酒杯
七夕来袭!是时候展现专属于程序员的浪漫了!你打算怎么给心爱的人表达爱意?鲜花礼物?代码表白?还是创意DIY?或者…无论那种形式,快来秀我们一脸吧!
效果
html代码
<div class="valentines-day">
<div class="envelope"></div>
<div class="heart"></div>
<div class="text">HAPPY 520 DAY!</div>
<div class="front"></div>
<div class="text2">- hover over the envelope - </div>
</div>
css代码
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f1e3d3;
overflow: hidden;
}
.valentines-day {
position: relative;
cursor: pointer;
}
.envelope {
position: relative;
filter: drop-shadow(0 0 25px rgba(0,0,0,.3));
}
.envelope:before {
content:"";
position: absolute;
width:254px;
height:254px;
background-color: #ff9494;
transform: rotate(-45deg);
border-radius: 0 15px 0 0;
left:-37px;
top:-82px;
}
.envelope:after {
content:"";
position: absolute;
background-color: #ff9494;
width:360px;
height:225px;
left:-90px;
top:45px;
}
.heart {
position: relative;
background-color: #e01911;
display: inline-block;
height: 180px;
top:50px;
left:0;
transform: rotate(-45deg);
width:180px;
filter: drop-shadow(0 -10px 25px rgba(0,0,0,.3));
transition: .5s;
}
.heart:before, .heart:after {
content:"";
background-color: #e01911;
border-radius:50%;
height: 180px;
width: 180px;
position: absolute;
}
.heart:before {
top:-100px;
left:0;}
.heart:after {
left:100px;
top:0;}
.front {
position: absolute;
width:0;
height:0;
border-right: 190px solid #fbd2d2;
border-top: 113px solid transparent;
border-bottom: 113px solid transparent;
top:44px;
left:80px;
z-index:4;
}
.front:before {
content:"";
position: absolute;
width:0;
height:0;
border-left: 190px solid #fbd2d2;
border-top: 113px solid transparent;
border-bottom: 113px solid transparent;
top:-113px;
left:-170px;
}
.front:after {
width:0;
height:0;
position: absolute;
content:"";
border-bottom: 150px solid #fce7e9;
border-right:180px solid transparent;
border-left: 180px solid transparent;
top:-36px;
left:-170px;
}
.text {
position: absolute;
font-family: arial;
letter-spacing:5px;
text-align: center;
color: white;
z-index:2;
top:80px;
left:15px;
transition: .5s;
}
.valentines-day:hover .heart {
transform: translateY(-50px) rotate(-45deg);
}
.valentines-day:hover .text {
transform: translateY(-50px);
}
.text2 {
position: absolute;
top:275px;
color: white;
font-family: brush script mt;
text-align: center;
width:195px;
font-size:20px;
}
效果
html代码
<h2>Have Dinner with Me<br/> On Friday?</h2>
<div id="heart">
</div>
<div class="glass-wrapper">
<div class="top">
<div class="liquid">
<div class="shadow">
</div>
</div>
<div class="shadow2"></div>
</div>
<div class="stand"></div>
<div class="bottom"></div>
<div class="heart h1"></div>
<div class="heart h2"></div>
<div class="heart h3"></div>
<div class="heart h4"></div>
<div class="heart h5"></div>
<div class="heart h6"></div>
</div>
css代码
body {
background-color: #fe9cd1;
font-family: 'Dancing Script', cursive; }
h2 {
text-align: center;
margin-top: 40px;
font-size: 50px;
color: #333; }
#heart {
position: absolute;
left: calc(50% - 200px);
top: calc(50% - 180px);
width: 400px;
height: 360px;
opacity: 0.2; }
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 200px;
top: 0;
width: 200px;
height: 360px;
background: red;
-moz-border-radius: 100px 1000px 0 0;
border-radius: 100px 100px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%; }
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%; }
.glass-wrapper {
position: absolute;
left: calc(50% - 150px);
top: calc(50% - 230px);
width: 300px;
height: 500px;
cursor: pointer; }
.glass-wrapper:hover {
animation: shake 1.3s ease; }
.top {
position: absolute;
left: 70px;
top: 80px;
width: 150px;
height: 250px;
overflow: hidden;
border: 5px solid #333;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 60%;
border-bottom-right-radius: 60%;
z-index: 2; }
.top .liquid {
position: absolute;
bottom: 0;
width: 150px;
height: 150px;
background-color: #c0392b; }
.top .liquid .shadow {
position: absolute;
bottom: -100px;
right: -100px;
width: 300px;
height: 300px;
background-color: transparent;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
border: 100px solid rgba(0, 0, 0, 0.2); }
.top .shadow2 {
position: absolute;
left: 20px;
top: 10px;
width: 10px;
height: 160px;
background-color: rgba(255, 255, 255, 0.3);
border-bottom-left-radius: 100%; }
.stand {
position: absolute;
left: 142px;
top: 338px;
width: 5px;
height: 100px;
border: 5px solid #333;
border-top-width: 2px;
border-bottom: 0;
background-color: rgba(255, 255, 255, 0.3); }
.bottom {
position: absolute;
left: 90px;
top: 438px;
width: 110px;
height: 5px;
border: 5px solid #333;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
background-color: rgba(255, 255, 255, 0.3); }
.heart {
position: absolute;
width: 100px;
height: 90px;
top: 200px; }
.heart.h1 {
left: 120px;
animation: transition-up 5s ease-in-out 1s infinite; }
.heart.h2 {
left: 150px;
animation: transition-up 5s ease-in-out infinite; }
.heart.h3 {
animation: transition-up 5s ease-in-out 2s infinite;
left: 90px; }
.heart.h4 {
animation: transition-up 5s ease-in-out 3s infinite;
left: 115px; }
.heart.h5 {
animation: transition-up 5s ease-in-out 4s infinite;
left: 135px; }
.heart.h6 {
animation: transition-up 5s ease-in-out 3.5s infinite;
left: 140px; }
.heart:before, .heart:after {
position: absolute;
content: "";
left: 25px;
top: 0;
width: 25px;
height: 40px;
background: #c0392b;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%; }
.heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%; }
@keyframes transition-up {
0% {
transform: translate3d(20px, 0, 0); }
20% {
transform: translate3d(-20px, 0, 0); }
40% {
transform: translate3d(20px, 0, 0); }
60% {
opacity: 1;
transform: translate3d(-20px, 0, 0); }
80% {
transform: translate3d(10px, 0, 0); }
100% {
opacity: 0;
top: 10px;
transform: translate3d(-10px, 0, 0); } }
@keyframes shake {
0% {
transform: rotate(0); }
25% {
transform: rotate(10deg); }
50% {
transform: rotate(-10deg); }
75% {
transform: rotate(5deg); }
100% {
transform: rotate(0deg); } }
/*# sourceMappingURL=index.css.map */
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634074.html