css布局实现带立体深度卡片效果代码

代码语言:html

所属分类:布局界面

代码描述:css布局实现带立体深度卡片效果代码

代码标签: css 立体 深度 卡片

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


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

<head>

  <meta charset="UTF-8">
  

  <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.0.css">
  
  
<style>

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box }
body {
  padding: 2rem;
  font-family: 'Roboto', sans-serif;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background-color: #060606;
}
ul{
  width: min(100%, 60rem);
  overflow: hidden;
  margin-inline: auto;
  padding-inline: clamp(1rem, 5vw, 4rem);
  list-style: none;
  perspective: 1000px;
  display: grid;
  row-gap: 0.5rem;
}
ul li.card{
  position: relative;
  padding-block: 1.5rem;
  padding-inline: 2rem;
  background-color: var(--bg-color);
  background-image: linear-gradient(to right, rgb(0 0 0 / .15), transparent);
  transform-style: preserve-3d;
  color: var(--color);
  
  display: grid;
  grid-template: 'icon' 'title' 'content';
  row-gap: 0.5rem;
  column-gap: 2rem;
}
ul li.card::before, ul li.card::after {
  --side-rotate: 60deg;
  content: "";
  position: absolute;
  top: 0;
  height: 100%;
  width: 100%;
  transform-origin: calc(50% - (50% * var(--ry))) 50%  ;
  transform: rotateY(calc(var(--side-rotate) * var(--ry)));
  background-color: inherit;
  background-image: linear-gradient(calc(90deg * var(--ry)), rgb(0 0 0 / .25), rgb(0 0 0 / .5));  
}
ul li.card::before {--ry: -1; right: 100% }
ul li.card::after {--ry: 1; left: 100% }

ul li.card .icon {
  grid-area: icon;
  display: grid;
  place-items: center;
}
ul li.card .icon i {
  font-size: 2rem;
}
ul li.card .title{
  grid-area: title;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
ul li.card .content{
  grid-area: content;
}

@media (min-width: 30rem){
  ul li.card {
    grid-template: 'icon title' 'icon content';
    text-align: left;
  }
  ul li.card .title { text-align: left }
}
</style>



</head>

<body  >
  <ul>
  <li class="card" style="--color:#ececec; --bg-color:#E98B43">
    <div class="icon"><i class="fa-solid fa-house"></i></div>
    <div class="title">Lorem ipsum</div>
    <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis pretium euismod. Aenean elit sapien, varius qu.........完整代码请登录后点击上方下载按钮下载查看

网友评论0