css+js实现图文卡片鼠标悬浮交互视觉差异效果代码

代码语言:html

所属分类:视觉差异

代码描述:css+js实现图文卡片鼠标悬浮交互视觉差异效果代码

代码标签: css js 图文 卡片 鼠标 悬浮 交互 视觉差异

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


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

<head>

  <meta charset="UTF-8">
  

  
  
  
  
<style>
.phce {
  perspective: 1000px;
  position: relative;
}
.phce .content {
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
}
.phce .content::before, .phce .content::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transform-style: preserve-3d;
}
.phce .content::before {
  background-image: var(--bg-image);
  background-size: cover;
}
.phce .content::after {
  background: var(--bg-overlay, none);
}
.phce:hover > .content::before {
  transform: scale(1.33) translateX(calc(-12.5% * var(--posX,0))) translateY(calc(-12.5% * var(--posY,0)));
}
.phce:hover > .content {
  transform: rotateX(calc(22.5deg * var(--posY,0))) rotateY(calc(-22.5deg * var(--posX,0)));
}
.phce:not(:hover) > .content, .phce:not(:hover) > .content::before {
  transition: transform var(--transition-duration, 500ms) var(--transition-timing-function, linear);
}

.card {
  width: min(30rem, 100%);
}

.card-1 {
  --bg-image: url(//repo.bfw.wiki/bfwrepo/image/634f71a6d2293.png) ;
}

.card-2 {
  --bg-image: url(//repo.bfw.wiki/bfwrepo/image/635f4245169a2.jpeg) ;
}

.content {
  display: grid;
  place-items: center;
  min-height: 16rem;
  padding: 2rem;
  border-radius: 1rem;
  font-family: system-ui, sans-serif;
  font-size: 2rem;
  color: white;
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0