DEV Community

Cover image for Learn how to create a awesome cards component using HTML & CSS only
EHSAN.
EHSAN.

Posted on • Edited on • Originally published at your-codes.vercel.app

Learn how to create a awesome cards component using HTML & CSS only

In this article you are going to learn some awesome features of CSS by creating this image hover able effects

Image description

this component is mainly possible because of this css trick

.list .item:hover + * {
  filter: brightness(0.6);
  transform: translateZ(150px) rotateY(40deg);
}

.list .item:hover + * + * {
  filter: brightness(0.4);
  transform: translateZ(70px) rotateY(20deg);
}

.list .item:hover + * + * + * {
  filter: brightness(0.2);
  transform: translateZ(30px) rotateY(10deg);
}
.list .item:has(+ *:hover) {
  filter: brightness(0.6);
  transform: translateZ(150px) rotateY(-40deg);
}

.list .item:has(+ * + * :hover) {
  filter: brightness(0.4);
  transform: translateZ(70px) rotateY(-20deg);
}

.list .item:has(+ * + * + *:hover) {
  filter: brightness(0.2);
  transform: translateZ(30px) rotateY(-10deg);
}
Enter fullscreen mode Exit fullscreen mode

💡 Did you noticed that :hover + * and :has(+ *:hover) properties of CSS is such a valuable & time saving ⌚ feature.

Just look it we do not need any JavaScript to handle this kind of functionality.

get complete code

To get complete code you can follow this post 👇
https://your-codes.vercel.app/create-a-awesome-and-hover-able-card-component-using-html-and-css-only-with-source-code

Top comments (0)