给大家分享一个用CSS 3.0实现的创意产品卡片,效果如下:
以下是代码实现,欢迎大家复制粘贴和收藏。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<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;
background-color: #131313;
min-height: 100vh;
}
.container {
position: relative;
}
.container .card {
position: relative;
width: 320px;
height: 450px;
background: #232323;
border-radius: 20px;
overflow: hidden;
}
.container .card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #9bdc28;
clip-path: circle(150px at 80% 20%);
transition: 0.5s ease-in-out;
}
.container .card:hover::before {
clip-path: circle(300px at 80% -20%);
}
.container .card .img-box {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 1000;
height: 220px;
width: 100%;
transition: 0.5s;
}
.container .card:hover .img-box {
top: 0%;
transform: translateY(0);
}
.container .card .img-box img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(0deg);
width: 270px;
}
.container .card .content-box {
position: absolute;
bottom: 0;
width: 100%;
height: 100px;
text-align: center;
transition: 1s;
z-index: 0;
}
.container .card:hover .content-box {
height: 210px;
}
.container .card .content-box h2 {
position: relative;
font-weight: 600;
letter-spacing: 1px;
color: #fff;
}
.container .card .content-box .size,
.container .card .content-box .color {
display: flex;
justify-content: center;
align-items: center;
padding: 8px 20px;
transition: 0.5s;
opacity: 0;
visibility: hidden;
}
.container .card:hover .content-box .size {
opacity: 1;
visibility: visible;
transition-delay: 0.5s;
}
.container .card:hover .content-box .color {
opacity: 1;
visibility: visible;
transition-delay: 0.6s;
}
.container .card .content-box .size h3,
.container .card .content-box .color h3 {
color: #fff;
font-weight: 300;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 2px;
margin-right: 10px;
}
.container .card .content-box .size span {
width: 26px;
height: 26px;
text-align: center;
line-height: 26px;
font-size: 14px;
display: inline-block;
color: #111;
background: #fff;
margin: 0 5px;
color: #111;
border-radius: 4px;
cursor: pointer;
}
.container .card .content-box .size span:hover {
background: #9bdc28;
}
.container .card .content-box .color span {
width: 20px;
height: 20px;
background: #ff0;
border-radius: 50%;
margin: 0 5px;
cursor: pointer;
}
.container .card .content-box .color span:nth-child(2) {
background: #9bdc28;
}
.container .card .content-box .color span:nth-child(3) {
background: #03a9f4;
}
.container .card .content-box .color span:nth-child(4) {
background: #e91e63;
}
.container .card .content-box a {
display: inline-block;
padding: 10px 20px;
background: #fff;
border-radius: 4px;
margin-top: 10px;
text-decoration: none;
font-weight: 600;
color: #111;
opacity: 0;
transform: translateY(50px);
transition: 0.5s;
}
.container .card:hover .content-box a {
opacity: 1;
transform: translateY(0px);
transition-delay: 0.75s;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="img-box">
<img src="http://pngimg.com/uploads/running_shoes/running_shoes_PNG5793.png" alt="">
</div>
<div class="content-box">
<h2>耐克(NIKE)运动鞋</h2>
<div class="size">
<h3>Size:</h3>
<span>7</span>
<span>8</span>
<span>9</span>
<span>10</span>
</div>
<div class="color">
<h3>Color:</h3>
<span></span>
<span></span>
<span></span>
</div>
<a href="#">立即购买</a>
</div>
</div>
</div>
</body>
</html>