Day # 73: 3D List Hover



A few days ago I came across a website that had a cool effect when you hovered on certain images. I had the impression that their developers had made some version of a 3D effect on those images.

After inspecting that website for a few minutes, I discovered that they had indeed worked with the translateZ value. I decided then to learn more about this value and then practice it with a concrete project.

Today’s project consists of adding a 3D effect on a list of tiny cards, emulating notifications on a mobile phone for a certain app. The key here was play around with the translateZ value of several images to coordinate their form of appearance: 


ul li:nth-child(1) {

    transform: translateZ(-75px) translateY(20px);

}

Throughout this project I ran into a problem with some of the images I downloaded. I needed them to be squared, but I didn’t want to edit them with an image software. I wanted to able to do so using CSS, so I found the object-fit property: 


Crop image

 src="https://example.com/myimage.png">


.cropped-ofp {

width: 150px; 

height: 150px; 

object-fit: cover;

object-position: 25% 25%; 

}


 

Comments

Popular posts from this blog

Day # 35: Flip Book

Day # 1: Homepage w/Introduction

Day # 8: Inspiration