<img data-src="https://assets.codepen.io/14179/musab-al-rawahi-KsfH7IYFn98-unsplash.jpg" src="" alt="Photograph of hot air balloons by Musab Al Rawahi. 144kb" />
body {
  font-size: 120%;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  padding: 60px;
}

code {
  background: #eee;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  display: block;
}

img {
  cursor: pointer;
  width: 900px;
  max-width: 100%;
  aspect-ratio: 1.5/1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  color: white;
  border-radius: 10px;
  transition: all 0.3s ease;

  &:hover {
    transform: scale(1.05);
  }

  &:before {
    border-radius: 15px;
    position: relative;
    background: #ccc;
    z-index: 1;
    height: 100%;
    color: black;
    content: attr(alt);
    display: grid;
    place-items: center;
  }
}

.load-image {
  display: block;
  background: #ccc;
  height: 400px;
  width: 100%;
  border-radius: 15px;
  display: grid;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: black;
  opacity: 0.7;
  transition: all 0.3s ease;

  &:hover {
    opacity: 1;
  }
}
View Compiled
document.querySelectorAll("img").forEach((item) => {
  item.addEventListener("click", (event) => {
    const image = event.target.getAttribute("data-src");
    event.target.setAttribute("src", image);
  });
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.