给大家分享一个由CSS 3.0实现的立体卡片特效,效果如下:
以下是代码实现,欢迎大家复制粘贴和收藏。
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS 3.0实现立体卡片特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: '微软雅黑', sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #f3f3f3;
overflow: hidden;
}
.container {
position: relative;
width: 1050px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
transform: skewY(-10deg);
}
.container .card {
position: relative;
width: 300px;
height: 400px;
background: #fff;
transition: 0.5s;
}
.container .card::before {
content: '';
position: absolute;
top: -15px;
left: 0;
width: 100%;
height: 15px;
background: #00c0f6;
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
}
.container .card::after {
content: '';
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 50%;
background: #00c0f6;
transform-origin: left;
transform: skewX(45deg);
transition: 0.5s;
transform: skewY(45deg);
border-bottom: 200px solid #d9d9d9;
}
.container .card:hover {
transform: translateY(-40px);
}
.container .card .imgBx {
position: relative;
width: 300px;
height: 200px;
background: #00c7ff;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.container .card .imgBx img {
max-width: 100px;
}
.container .card .imgBx h3 {
position: relative;
color: #fff;
margin-top: 10px;
}
.container .card .content {
position: relative;
width: 100%;
height: 200px;
padding: 20px;
text-align: center;
background: #fff;
}
.container .card .content::before {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 400px;
background: linear-gradient(transparent, transparent, rgba(0, 0, 0, .1));
transform: skewX(45deg);
transform-origin: bottom;
transition: 0.5s;
pointer-events: none;
z-index: -1;
}
.container .card:hover .content::before {
transform: translateY(40px) skewX(45deg);
filter: blur(5px);
opacity: 0.5;
}
.container .card:nth-child(1) {
z-index: 3;
}
.container .card:nth-child(2) {
z-index: 2;
}
.container .card:nth-child(3) {
z-index: 1;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="imgBx">
<img src="http://pngimg.com/uploads/running_shoes/running_shoes_PNG5793.png" alt="">
<h3>设计</h3>
</div>
<div class="content">
任何时候,无论你面临着生命的何等困惑,抑或经受着多少挫折,无论道路如何的艰难,无论希望变得如何渺茫,请你不要绝望,再试一次,成功一定属于你!
</div>
</div>
<div class="card">
<div class="imgBx">
<img src="http://pngimg.com/uploads/running_shoes/running_shoes_PNG5793.png" alt="">
<h3>编码</h3>
</div>
<div class="content">
任何时候,无论你面临着生命的何等困惑,抑或经受着多少挫折,无论道路如何的艰难,无论希望变得如何渺茫,请你不要绝望,再试一次,成功一定属于你!
</div>
</div>
<div class="card">
<div class="imgBx">
<img src="http://pngimg.com/uploads/running_shoes/running_shoes_PNG5793.png" alt="">
<h3>成长</h3>
</div>
<div class="content">
任何时候,无论你面临着生命的何等困惑,抑或经受着多少挫折,无论道路如何的艰难,无论希望变得如何渺茫,请你不要绝望,再试一次,成功一定属于你!
</div>
</div>
</div>
</body>
</html>