前端特效-HTML+CSS+JS -3D翻转动画效果的名片

实现的效果

前端特效-HTML+CSS+JS -3D翻转动画效果的名片_第1张图片

项目需要的图片资源

html部分 + js部分


<html lang="en" dir="ltr">
 <head>
   <meta charset="utf-8">
   <title>title>
   <link rel="stylesheet" href="style.css">
   <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">script>

 head>
 <body>

   <div class="business-card middle">
     <div class="front">
       <h2>Shuichi Akaih2>
       <span>Web Designerspan>
       <ul class="contact-info">
         <li>
           <i class="fas fa-mobile-alt">i> +0000000000
         li>
         <li>
           <i class="far fa-envelope">i> [email protected]
         li>
         <li>
           <i class="fas fa-map-marker-alt">i> Tokyo, Japan
         li>
       ul>
     div>
     <div class="back">
       <span>DarkCodespan>
     div>
   div>

   <script>
     $(".business-card").click(function(){
       $(".business-card").toggleClass("business-card-active");
     });
   script>
 body>
html>

css部分

*{
  margin: 0;
  padding: 0;
  font-family: "montserrat",sans-serif;
  box-sizing: border-box;
  list-style: none;
}

body{
  background: url(bg.jpg) no-repeat;
  background-size: cover;
  user-select: none;
}

.business-card{
  width: 500px;
  height: 280px;
}

.middle{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

.front,.back{
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: absolute;
  backface-visibility: hidden;
  transition: transform 0.5s linear;
}

.front{
  background: rgba(255,255,255,.7);
  padding: 40px;
  transform: perspective(600px) rotateX(180deg);
}

.front::before,.front::after{
  content: "";
  position: absolute;
  right: 0;
}

.front::before{
  background: #2c3e50;
  width: 80px;
  height: 120px;
  bottom: 0;
  clip-path:polygon(0 100%,40% 0,100% 100%);
}

.front::after{
  background: #34495e;
  width: 100px;
  height: 100%;
  top: 0;
  clip-path:polygon(0 0,100% 0,100% 100%,80% 100%);
}

.front h2{
  text-transform: uppercase;
}

.front span{
  background: #34495e;
  color: #fff;
  padding: 4px 10px;
  display: inline-block;
  margin-bottom: 20px;
  font-size: 14px;
}

.front .contact-info li{
  margin: 10px 0;
  display: flex;
  align-items: center;
}

.front .contact-info li i{
  width: 26px;
  height: 26px;
  background: #34495e;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 6px;
}

.back{
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 8px;
  font-size: 24px;
  transform: perspective(600px) rotateX(0deg);
}

.business-card-active .front{
  transform: perspective(600px) rotateX(0deg);
}
.business-card-active .back{
  transform: perspective(600px) rotateX(-180deg);
}

你可能感兴趣的:(前端特效)