<heading>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pure CSS Card Hover Effect</title>
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
</heading>
<center>
<h1 class="title">Pure CSS Profile Card Hover Effect</h1>
</center>
<div class="container">
<div class="profile-card">
<div class="content">
<h1>Diego Maradona</h1>
<h2>(1989–2003)</h2>
</div>
</div>
</div>
<center>
<h1 class="title">Hover & Enjoy</h1>
</center>
* {
box-sizing: border-box;
margin:0px;
padding:0px;
}
.title{
font-size:60px;
padding:20px 0px;
}
body {
font-family: 'Lato', sans-serif;
background-color:#eaeaea;
}
.container{
width:900px;
margin:0px auto;
text-align:center;
}
.profile-card{
margin:0px auto;
width:300px;
height:450px;
overflow:hidden;
background:#fff;
padding:10px;
border-radius:10px;
box-shadow:0px 2px 6px rgba(0,0,0,0.2);
background-image:url('https://github.com/free-source-code-bd/all-public-resource/blob/main/maradona%20(3).jpg?raw=true');
background-repeat: no-repeat;
background-size: 300px 350px;
cursor:pointer;
transition:0.7s;
}
.profile-card:hover{
background-image:url('https://github.com/free-source-code-bd/all-public-resource/blob/main/maradona%20(2).jpg?raw=true');
background-repeat: no-repeat;
background-size: 300px 450px;
transition:1s;
}
.profile-card{
position:relative;
}
.profile-card .content{
position:absolute;
width:100%;
bottom:20px;
left:0;
transition:1s;
}
.profile-card .content h1{
font-size:25px;
padding-bottom:5px;
}
.profile-card .content h2{
font-size:18px;
}
.profile-card:hover .content{
bottom:-15%;
}
/* Responsive columns */
@media screen and (max-width: 300px) {
.container{
width: 100%;
}
.profile-card {
width: 100%;
display: block;
margin-bottom: 20px;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.