Creates a CSS HTML card which reveals more content within a html element on hover. The code utilises display, object-fit, transition. Sourced under a permissive license.

CSS and HTML code to apply perspective transform with animation on mouse over (hover) element

<div class="card">
  <img src="https://codesnippetsandtutorials.com/wp-content/uploads/2023/07/swati-b-Vf2-ZiIu8xY-unsplash-1-840x400.jpg"/>
  <h3>Lorem ipsum</h3>
  <div class="focus-content">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br/> <a href="#">Link to source</a>
    </p>
  </div>
</div>

<style>
.card {
  width: 300px;
  height: 280px;
  padding: 0;
  box-shadow: 0 2px 4px 0 rgba(0,0,0,0.1);
  border-radius: 8px;
  box-sizing: border-box;
  overflow: hidden;
}

.card * {
  transition: 0.3s ease all;
}

.card img {
  margin: 0;
  width: 300px;
  height: 224px;
  object-fit: cover;
  display: block;
}

.card h3 {
  margin: 0;
  padding: 12px 12px 48px;
  line-height: 32px;
  font-weight: 500;
  font-size: 20px;
}

.card .focus-content {
  display: block;
  padding: 8px 12px;
}

.card p {
  margin: 0;
  line-height: 1.5;
}

.card:hover img, .card:focus-within img {
  margin-top: -80px;
}

.card:hover h3, .card:focus-within h3 {
  padding: 8px 12px 0;
}
</style>

Tags: CSS, HTML, CSS, CSS code snippet, html code snippet, object-fit, transition, reveal div css, reveal html element, css hover, hover, css display, css display

Image: Unsplash license

CC BY 4.0 added intro and tags – 30 Seconds of Code