div+css实现文字卡片堆叠悬浮靠前置顶显示效果代码

代码语言:html

所属分类:悬停

代码描述:div+css实现文字卡片堆叠悬浮靠前置顶显示效果代码

代码标签: div css 文字 卡片 堆叠 悬浮 靠前 置顶 显示

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

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

<head>
  <meta charset="UTF-8">
  

<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" rel="stylesheet">

  
<style>
body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background: #242424;
}
body h2,
body p {
  margin: 0;
  font: inherit;
}
body h2 {
  font-size: 1.25rem;
  font-weight: 500;
}
body .card_stack {
  --card-shown-x: 5rem;
  --card-shown-y: 3rem;
  --card-size-x: 12rem;
  --card-size-y: 8rem;
  --card-padding: 1rem;
  display: flex;
  flex-direction: column;
  padding-right: calc(var(--card-size-x) - var(--card-shown-x) + 2 * var(--card-padding));
  padding-bottom: calc(var(--card-size-y) - var(--card-shown-y) + 2 * var(--card-padding));
}
body .card_stack .card_container {
  position: relative;
  margin-left: calc((var(--num) - 1) * var(--card-shown-x));
  width: var(--card-shown-x);
  height: var(--card-shown-y);
}
body .card_stack .card_container:nth-child(1) {
  --num: 1;
}
body .card_stack .card_container:nth-child(2) {
  --num: 2;
}
body .card_stack .card_container:nth-child(3) {
  --num: 3;
}
body .card_stack .card_container:nth-child(4) {
  --num: 4;
}
body .card_stack .card_container:nth-child(5) {
  --num: 5;
}
body .card_stack .card_container .card {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: var(--card-size-x);
  min-height: var(--card-size-y);
  padding: var(--card-padding);
  border-radius: 1rem;
  background: #2c2c2c;
  color: #fff;
  box-shadow: 0 0 1.5rem -0.25rem rgba(0,0,0,0.75);
}
body .card_stack .card_container .card.ghost {
  z-index: 1;
  opacity: 0;
  transition: 0.25s ease;
}
body .card_stack .card_container:not(:hover) .ghost {
  pointer-events: none;
}
body .card_stack .card_container:hover .ghost {
  opacity: 1;
}
</style>

  
  
  
</head>

<body>
  <div class="card_stack">
  <div class="card_container">
    <div class="card">
      <h2>.........完整代码请登录后点击上方下载按钮下载查看

网友评论0