html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Design | CSS Cards</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="container">
<div class="card">
<div class="imgBx" style="--img: url(../images/img1.jpg)"></div>
<div class="content">
<h3>New Design<br><span>2 Hours ago</span></h3>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolorem error iure sequi neque animi!
Harum?</p>
</div>
</div>
<div class="card">
<div class="imgBx" style="--img: url(../images/img2.jpg)"></div>
<div class="content">
<h3>CSS Only<br><span>5 Hours ago</span></h3>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolorem error iure sequi neque animi!
Harum?</p>
</div>
</div>
</div>
</body>
</html>
css代码
body {
display: flex;
margin: 0;
padding: 0;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #333;
font-family: 'Poppins', sans-serif;
}
.container {
position: relative;
display: flex;
align-items: center;
gap: 50px;
}
.container .card {
position: relative;
width: 300px;
height: 300px;
background-color: #fff;
border-radius: 40px;
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.25);
transition: 0.5s;
overflow: hidden;
}
.container .card:hover {
height: 420px;
}
.container .card .imgBx {
position: relative;
width: 100%;
height: 260px;
background-color: #555;
background-image: var(--img);
background-size: 100%;
background-position: center;
transition: 0.5s;
filter: blur(25px);
}
.container .card:hover .imgBx{
background-size: 120%;
filter: blur(0);
}
.container .card .imgBx::before {
content: '';
position: absolute;
bottom: -40px;
width: 100%;
height: 80px;
border-radius: 40px;
background-color: #fff;
}
.container .card .imgBx::after {
content: '';
position: absolute;
right: 0;
bottom: 40px;
width: 80px;
height: 80px;
border-radius: 40px;
background-color:transparent;
border-radius: 50%;
box-shadow: 75px 70px 0 40px #fff;
}
.container .card .content {
position: relative;
top: -40px;
padding: 0 30px;
transition: 0.5s;
z-index: 10;
}
.container .card .content h3 {
position: relative;
font-size: 1.25em;
color: #333;
}
.container .card .content h3 span {
position: absolute;
bottom: -15px;
font-weight: 400;
font-size: 0.65em;
opacity: 0.75;
}
.container .card .content p {
position: relative;
opacity: 0;
transition: 0.5s;
color: #333;
}
.container .card:hover .content p {
opacity: 1;
transition-delay: 0.2s;
}
转自公众号: 枫瑞博客网
如有侵权 请联系删除