I have developed an animation for my website, to give the effect of polaroid photos being tossed across a table top. I did this using the following html and CSS. It works in Codepen.(The changing font colors are just to identify the media query is working.)
https://codepen.io/Liam-Robb-OHagan/pen/YPPRYOO
HTML…
<div class="hero-wrapper">
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Grand-Teton-Winter-Bison-Plow-Framed.jpg" class="imgBison" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/03/Shoshone-Petrogylphs-Water-Ghost_ZoomedIN.jpg" class="imgPetroglyph" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Fairy-Retro-Frame-Vertical.jpg" class="imgHike" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Shoshone-Petrogylphs-Moose-Framed.jpg" class="imgMoose" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Grand-Teton-Summer-Grizzly-Delayed-Implantation-Framed.jpg" class="imgGrizzly" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Grand-Teton-Wildflowers-Framed.jpg" class="imgTetons" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Yellowstone-2-Day-Wolf-Framed.jpg" class="imgWolf" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/Hero-Grand-Prismatic-Spring-Framed-scaled.jpg" class="imgSpring" />
<img src="https://guidesofjacksonhole.com/wp-content/uploads/2025/01/HIke-Upper-Retro-Frame-Vertical.jpg" class="imgGeyser" />
<div class="hero-text">
<div class="hero-h1">
Your Adventure of a Lifetime
</div>
<div class="hero-h3">
Forge Your Own Memories on Our Private Wildlife Safaris and Interpretive Tours of Grand Teton & Yellowstone National Parks.
</div>
</div>
CSS…
/*Default ViewPort MOBILE 320-480px*/
/*Hero Container*/
.hero-wrapper {
position: relative;
background-image: url(https://guidesofjacksonhole.com/wp-content/uploads/2025/03/HeroBG-mb-480-720.jpg);
background-repeat: repeat-y;
background-size: cover;
background-position: center;
display: flex;
width: 100%;
max-width: 480px;
height: 720px;
max-height: 720px;
margin: auto;
overflow: hidden; /* Remove if images should be visible outside frame*/
}
/*Head and Subhead Container*/
.hero-text {
display: flex;
width: 90%;
flex-direction: column;
align-items: flex-start;
position: absolute;
left: 24px;
bottom: 24px;
}
.hero-h1 {
color: pink;
font-family: Simplo, Lato, sans serif;
font-size: 28px;
font-style: normal;
font-weight: 700;
line-height: normal; /* 92.857% */
letter-spacing: -1px;
text-transform: capitalize;
align-self: stretch;
width: 100%;
}
.hero-h3 {
color: purple;
font-family: Simplo, Lato, sans serif;
font-size: 22px;
font-style: normal;
font-weight: 700;
line-height: normal;
letter-spacing: -1px;
text-transform: capitalize;
width: 90%;
}
/*Image Container*/
.hero-wrapper img {
position: absolute;
width: 140px;
height: auto;
box-shadow: 3px 9px 12px 3px rgba(0, 0, 0, 0.4);
bottom: 25%;
left: 62%;
animation-duration: 2s;
animation-delay: 1s;
transition-timing-function: ease-out;
animation-fill-mode: forwards;
}
/*Individual Images and Starting Position to the bottom right of the screen*/
.hero-wrapper .imgBison {
right: 0;
transform: translate(100%, 0%) rotate(5deg);
animation-name: enterBison;
}
.hero-wrapper .imgGeyser {
right: 0;
transform: translate(100%, 0%) rotate(25deg);
animation-name: enterGeyser;
}
.hero-wrapper .imgGrizzly {
right: 0;
transform: translate(100%, 100%) rotate(10deg);
animation-name: enterGrizzly;
}
.hero-wrapper .imgHike {
right: 0;
transform: translate(100%, 0%) rotate(15deg);
animation-name: enterHike;
}
.hero-wrapper .imgMoose {
right: 0;
transform: translate(100%, 0%) rotate(15deg);
animation-name: enterMoose;
}
.hero-wrapper .imgPetroglyph {
right: 0;
transform: translate(100%, 0%) rotate(15deg);
animation-name: enterPetroglyph;
}
.hero-wrapper .imgSpring {
right: 0;
transform: translate(100%, 0%) rotate(25deg);
animation-name: enterSpring;
}
.hero-wrapper .imgTetons {
right: 0;
transform: translate(100%, 120%) rotate(20deg);
animation-name: enterTetons;
}
.hero-wrapper .imgWolf {
right: 0;
transform: translate(100%, 100%) rotate(5deg);
animation-name: enterWolf;
}
/*Individual Images Animation onto the Screen. Appearance of some photos being tossed onto a rough wooden table top*/
/*MOBILE 320-480px*/
/*Final Position of Animations so Images fit the Portrait Container*/
@media only screen and (min-width: 320px) and (max-width: 480px) {
@keyframes enterBison {
from {
transform: translate(100%, 0%) rotate(20deg);
}
to {
transform: translate(-5%, -30%) rotate(2deg);
}
}
@keyframes enterGeyser {
from {
transform: translate(100%, 0%) rotate(25deg);
}
to {
transform: translate(-5%, -130%) rotate(-15deg);
}
}
@keyframes enterGrizzly {
from {
transform: translate(100%, 100%) rotate(10deg);
}
to {
transform: translate(-100%, -235%) rotate(-28deg);
}
}
@keyframes enterHike {
from {
transform: translate(100%, 100%) rotate(25deg) scale(1.25);
}
to {
transform: translate(-10%, -225%) rotate(18deg) scale(1);
}
}
@keyframes enterMoose {
from {
transform: translate(100%, 0%) rotate(15deg);
}
to {
transform: translate(-165%, -180%) rotate(-8deg);
}
}
@keyframes enterPetroglyph {
from {
transform: translate(0%, 100%) rotate(5deg);
}
to {
transform: translate(-140%, -105%) rotate(-35deg);
}
}
@keyframes enterSpring {
from {
transform: translate(100%, 100%) rotate(25deg);
}
to {
transform: translate(-75%, -50%) rotate(-8deg);
}
}
@keyframes enterTetons {
from {
transform: translate(100%, 0%) rotate(20deg) scale(1.25);
}
to {
transform: translate(-75%, -160%) rotate(5deg) scale(1);
}
}
@keyframes enterWolf {
from {
transform: translate(100%, 100%) rotate(5deg);
}
to {
transform: translate(-165%, -40%) rotate(30deg);
}
}
}
/*TABLET, LAPTOP, DESKTOP 768-1440px*/
/*Final Position of Animations so Images fit Landscape Container*/
@media only screen and (min-width: 768px) and (max-width: 1440px) {
@keyframes enterBison {
from {
transform: translate(100%, 0%) rotate(20deg);
}
to {
transform: translate(-5%, -10%) rotate(2deg);
}
}
@keyframes enterGeyser {
from {
transform: translate(100%, 0%) rotate(25deg);
}
to {
transform: translate(-25%, -130%) rotate(-15deg);
}
}
@keyframes enterGrizzly {
from {
transform: translate(100%, 100%) rotate(10deg);
}
to {
transform: translate(-225%, -165%) rotate(-28deg);
}
}
@keyframes enterHike {
from {
transform: translate(100%, 100%) rotate(25deg) scale(1.25);
}
to {
transform: translate(-320%, -175%) rotate(18deg) scale(1);
}
}
@keyframes enterMoose {
from {
transform: translate(100%, 0%) rotate(15deg);
}
to {
transform: translate(-350%, -90%) rotate(-8deg);
}
}
@keyframes enterPetroglyph {
from {
transform: translate(0%, 100%) rotate(5deg);
}
to {
transform: translate(-220%, -90%) rotate(-35deg);
}
}
@keyframes enterSpring {
from {
transform: translate(100%, 100%) rotate(25deg);
}
to {
transform: translate(-65%, -70%) rotate(-8deg);
}
}
@keyframes enterTetons {
from {
transform: translate(100%, 0%) rotate(20deg) scale(1.25);
}
to {
transform: translate(-140%, -130%) rotate(5deg) scale(1);
}
}
@keyframes enterWolf {
from {
transform: translate(100%, 100%) rotate(5deg);
}
to {
transform: translate(-85%, -180%) rotate(30deg);
}
}
}
/*TABLET 768-1024px*/
@media only screen and (min-width: 768px) and (max-width: 1024px) {
.hero-wrapper {
position: relative;
background-image: url(https://guidesofjacksonhole.com/wp-content/uploads/2025/03/HeroBG-1024-720.jpg);
min-width: 744px;
max-width: 1024px;
height: 640px;
max-height: 640px;
}
.hero-text {
width: 90%;
left: 10%;
bottom: 36px;
}
.hero-h1 {
color: green;
font-size: 36px;
}
.hero-h3 {
color: red;
font-size: 24px;
width: 500px;
}
.hero-wrapper img {
width: 185px;
height: auto;
bottom: 0%;
left: 78%;
}
}
/*LAPTOP 1025-1280px*/
@media only screen and (min-width: 1025px) and (max-width: 1280px) {
.hero-wrapper {
position: relative;
background-image: url(https://guidesofjacksonhole.com/wp-content/uploads/2025/03/HeroBG-1024-720.jpg);
min-width: 1025px;
max-width: 1280px;
height: 680px;
max-height: 720px;
}
.hero-text {
width: 60%;
left: 10%;
bottom: 42px;
}
.hero-h1 {
color: lightblue;
font-size: 48px;
}
.hero-h3 {
color: orange;
font-size: 32px;
}
.hero-wrapper img {
width: 205px;
height: auto;
bottom: 5%;
left: 72%;
}
}
/*DESKTOP 1281-1440px*/
@media only screen and (min-width: 1281px) and (max-width: 1440px) {
.hero-wrapper {
position: relative;
background-image: url(https://guidesofjacksonhole.com/wp-content/uploads/2025/03/HeroBG-1024-720.jpg);
min-width: 1281px;
max-width: 1440px;
}
.hero-text {
width: 60%;
left: 10%;
bottom: 48px;
}
.hero-h1 {
color: lightgreen;
font-size: 60px;
}
.hero-h3 {
color: orange;
font-size: 39px;
}
.hero-wrapper img {
width: 225px;
height: auto;
bottom: 5%;
left: 70%;
}
}
However, if I add the Html and CSS to a code module in the wordpress Divi theme the images do not display at the right size and the animation does not execute.
https://guidesofjh.wpenginepowered.com/?page_id=330203
ChatGPT suggested adding CSS to hide images and then use javascript to trigger the animation after the page loads, but this did not resolve the issue.
CSS…
.hero-wrapper img {
opacity: 0; /* Hide images initially */
visibility: hidden; /* Hide images initially */
transition: opacity 0.5s ease, visibility 0s ease 0.5s; /* Gradual fade-in */
}
.hero-wrapper img.start-animation {
opacity: 1; /* Show images after animation starts */
visibility: visible;
}
JS…
document.addEventListener('DOMContentLoaded', function() {
const images = document.querySelectorAll('.wrapper img');
images.forEach((img) => {
img.classList.add('start-animation');
});
});
Any other suggestions would be appreciated. I’m a novice so hopefully I am making a simple mistake. There are probably two related issues. Cleaning up/tweaking the code, then getting it to run in the Divi environment. Hoping the first resolves the second.
I’m aware I could use CSS to write the captions on the images, but I just want to get something up and running first.