I am currently attempting to achieve a 3D wrap effect for images on my website, similar to the one showcased in this image.
The desired effect needs to closely resemble the image linked above.
Below is the CSS code I am using to try to implement this effect:
.gallery-wrap{
background-color: rgba(0,0,0,0);
-webkit-box-shadow: 0 0px 0px 0px black !important;
-moz-box-shadow: 0 0px 0px 0px black !important;
box-shadow: 0 0px 0px 0px black !important;
}
.gallery-wrap img{
transform: perspective(400px) rotateY(10deg) translateX(7.5%) translateY(30px);
margin-bottom: 5em !important;
background-color: rgba(0,0,0,0);
-webkit-box-shadow: 0 5px 7px -1px black;
-moz-box-shadow: 0 5px 7px -1px black;
box-shadow: 0 5px 7px -1px black;
}
.gallery-wrap div:after{
content: '';
width: 5%;
height: 96%;
background-image: url('<url of the same image the is to be wrapped>');
position: absolute;
top: 0px;
transform: perspective(250px) rotateY(-55deg) translateY(7px) translateX(-10px);
left: 0px;
background-size: 10% 750%;
background-position-x: 0%;
}
The current code works as intended, however, it does not work optimally for all images. Images with more height than width tend to cause issues with the existing code.
I am interested in finding a JavaScript algorithm or a free library that can accomplish this task effectively. The algorithm should be able to analyze the width and height of the img
element and generate appropriate transform
values for the code provided above.