3D card卡片悬停特效

3D card卡片悬停特效

Gif效果:

3D card卡片悬停特效

HTML代码:

<a href="#">
  <div class="card">
    <div class="wrapper">
      <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038676-90dbcafe160c160.jpg" class="cover-image" />
    </div>
    <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038786-74784a6aa3373b4.png" class="title" />
    <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038838-f9adb438a1c4c01.png" class="character" />
  </div>
</a>

<a href="#">
  <div class="card">
    <div class="wrapper">
      <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038523-ceda8e9307e8bdd.jpg" class="cover-image" />
    </div>
    <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038905-9d387cf419a0978.png" class="title" />
    <img src="https://media.mybj123.com/wp-content/uploads/2023/03/1679038950-515971040a5ccf1.png" class="character" />
  </div>
</a>

CSS代码

:root {
  --card-height: 300px;
  --card-width: calc(var(--card-height) / 1.5);
}
* {
  box-sizing: border-box;
}
body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #191c29;
}
.card {
  width: var(--card-width);
  height: var(--card-height);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0 36px;
  perspective: 2500px;
  margin: 0 50px;
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wrapper {
  transition: all 0.5s;
  position: absolute;
  width: 100%;
  z-index: -1;
}

.card:hover .wrapper {
  transform: perspective(900px) translateY(-5%) rotateX(25deg) translateZ(0);
  box-shadow: 2px 35px 32px -8px rgba(0, 0, 0, 0.75);
  -webkit-box-shadow: 2px 35px 32px -8px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 2px 35px 32px -8px rgba(0, 0, 0, 0.75);
}

.wrapper::before,
.wrapper::after {
  content: "";
  opacity: 0;
  width: 100%;
  height: 80px;
  transition: all 0.5s;
  position: absolute;
  left: 0;
}
.wrapper::before {
  top: 0;
  height: 100%;
  background-image: linear-gradient(
    to top,
    transparent 46%,
    rgba(12, 13, 19, 0.5) 68%,
    rgba(12, 13, 19) 97%
  );
}
.wrapper::after {
  bottom: 0;
  opacity: 1;
  background-image: linear-gradient(
    to bottom,
    transparent 46%,
    rgba(12, 13, 19, 0.5) 68%,
    rgba(12, 13, 19) 97%
  );
}

.card:hover .wrapper::before,
.wrapper::after {
  opacity: 1;
}

.card:hover .wrapper::after {
  height: 120px;
}
.title {
  width: 100%;
  transition: transform 0.5s;
}
.card:hover .title {
  transform: translate3d(0%, -50px, 100px);
}

.character {
  width: 100%;
  opacity: 0;
  transition: all 0.5s;
  position: absolute;
  z-index: -1;
}

.card:hover .character {
  opacity: 1;
  transform: translate3d(0%, -30%, 100px);
}

「点点赞赏,手留余香」

0

给作者打赏,鼓励TA抓紧创作!

微信微信 支付宝支付宝

还没有人赞赏,快来当第一个赞赏的人吧!

声明:
1. 本站所有文章教程及资源素材均来源于网络与用户分享或为本站原创,仅限用于学习和研究。
2. 如果内容损害你的权益请联系客服QQ:1642748312给予处理。
码云笔记 » 3D card卡片悬停特效

发表回复

IT互联网行业相关广告投放 更专业 更精准

立即查看 联系我们