前端杂谈 · Web

H5C3实现爱心信封效果

小编 · 6月25日 · 2020年

演示展示

今天爱分享给大家带来html5 SVG CSS3实现H5C3实现爱心信封效果特效效果【附完整源代码】,希望能够帮助到大家。 

H5C3实现爱心信封效果

HTML

<div class="bg-wrapper">
 <div class="envelope-wrapper">
  <div class="envelope">
   <div class="card">
    <span class="fa fa-close close-icon"></span>
    <div class="text">Love</div>
    </div>
  </div>
  <div class="heart"></div>
 </div>
</div>

CSS

@import url("https://cdn.bootcss.com/font-awesome/4.6.0/css/font-aw
.bg-wrapper {
 height: 100vh;
 display: flex;
 justify-content: center;
 align-items: center;
 background-color: #D46466;
}
.bg-wrapper .envelope-wrapper {
 background: #B4D2EE;
}
.bg-wrapper .envelope-wrapper .envelope {
 position: relative;
 width: 150px;
 height: 100px;
}
.bg-wrapper .envelope-wrapper .envelope:before {
 content: "";
 position: absolute;
 top: 0px;
 z-index: 2;
 border-top: 55px solid #D3EAFD;
 border-right: 75px solid transparent;
 border-left: 75px solid transparent;
 transform-origin: top;
 transition: all 0.5s ease-in-out 0.7s;
}
.bg-wrapper .envelope-wrapper .envelope:after {
 content: "";
 position: absolute;
 z-index: 2;
 width: 0px;
 height: 0px;
 border-top: 50px solid transparent;
 border-right: 75px solid #B4D2EE;
 border-bottom: 50px solid #B4D2EE;
 border-left: 75px solid #B4D2EE;
}
.bg-wrapper .envelope-wrapper .envelope .card {
 position: absolute;
 right: 20%;
 bottom: 0;
 width: 60%;
 height: 90%;
 background: #FFF;
 text-align: center;
 transition: all 1s ease-in-out;
 box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
.bg-wrapper .envelope-wrapper .envelope .card .close-icon {
 position: absolute;
 right: 5px;
 top: 5px;
 font-size: 10px;
 color: rgba(68, 68, 68, 0.7);
 cursor: pointer;
}
.bg-wrapper .envelope-wrapper .envelope .card .text {
 position: absolute;
 top: 50%;
 left: 50%;
 font-family: "Great Vibes", cursive;
 color: #C51803;
 transform: translate(-50%, -50%);
}
.bg-wrapper .envelope-wrapper .heart {
 position: absolute;
 top: 50%;
 left: 50%;
 width: 15px;
 height: 15px;
 background: #C51803;
 z-index: 4;
 transform: translate(-50%, -20%) rotate(45deg);
 transition: transform 0.5s ease-in-out 1s;
 box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
 cursor: pointer;
}
.bg-wrapper .envelope-wrapper .heart:before, .bg-wrapper .envelope80 content: "";
 position: absolute;
 width: 15px;
 height: 15px;
 background-color: #C51803;
 border-radius: 50%;
}
.bg-wrapper .envelope-wrapper .heart:before {
 top: -7.5px;
}
.bg-wrapper .envelope-wrapper .heart:after {
 right: 7.5px;
}
.bg-wrapper .flap .envelope:before {
 transform: rotateX(180deg);
 z-index: 0;
}
.bg-wrapper .flap .envelope .card {
 bottom: 100px;
 transform: scale(1.5);
 transition-delay: 1s;
}
.bg-wrapper .flap .heart {
 transform: rotate(90deg);
 transition-delay: 0.4s;
}

JavaScript

$( document ).ready(() => {
 $(".envelope-wrapper .heart").click(() => {
 $('.envelope-wrapper').addClass('flap')
});

$(".envelope-wrapper .close-icon").click(() => {
 $('.envelope-wrapper').removeClass('flap')
 });
});
0 条回应

必须 注册 为本站用户, 登录 后才可以发表评论!