<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="card-image-root">
<img
class="card-image"
src="https://images.unsplash.com/photo-1527004013197-933c4bb611b3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=720&q=80"
>
<div class="card-image-overlay">
<a class="card-button" href="javascript:alert(1);">
Click me!!!
</a>
</div>
</div>
</body>
</html>
.card-image-root {
max-width: 300px;
height: auto;
position: relative;
}
.card-image-overlay {
display: none;
border-radius: 20px;
}
.card-image {
width: 100%;
border-radius: 20px;
}
.card-image-root:hover .card-image-overlay {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: rgba(0,0,0,.8);
position: absolute;
top: 0;
left: 0;
}
.card-button {
padding: 0.5rem 1.5rem;
border-radius: 10px;
background: white;
border: none;
cursor: pointer;
color: red;
text-decoration: none;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.