Upcoming

How To Make 3d Cube Effect Using Elementor Free

Tools and Links Used

Hostinger Fast, beginner friendly WordPress hosting.
Get Hosting
Elementor The free page builder this tutorial is built with.
Get Elementor
Elementor Pro The Pro upgrade used throughout this tutorial.
Get Elementor Pro
Kitpapa Ready made Elementor template kits.
Get Templates
Kitninja eCommerce Elementor template kits.
Get Templates
Project Files Download the resources used in this tutorial.
Download Files

Prompt Used in This Tutorial

3D Cube Effect Style CSS
<style>
body{
    overflow-x: hidden;
}
.services-card-text{
    mix-blend-mode: exclusion;
    }
    
#cube-section{
    position: relative;
}   
 
.scrollText, .scrollIcon {
  transition: transform 0.1s ease;
}
 
.from-left {
  transform: translate3d(-20vw, 0, 0);
}
 
.from-right {
  transform: translate3d(20vw, 0, 0);
}
 
.scrollIcon {
  display: inline-block; 
}
 
.elementor-image-box-wrapper{
    display: flex;
    justify-content: center;
    justify-items: center;
    align-items: center;
    gap: 20px;
}
 
.cube-wrapper {
    perspective: 100vh;
    transform-origin: 50%;
    display: flex; 
    justify-content: center; 
    align-items: center;     
    position: sticky !important;
    top: 50%; 
    transform: translateY(-50%); 
    width: 100%;            
}
 
@media (max-width: 767.98px){
    .cube-wrapper {
    transform: translateY(-245%);
}
}
 
#cube {
    pointer-events: auto;
    transform-origin: 50%;
    justify-content: center;
    align-items: center;
    display: flex
;
    position: relative;
    left: -29px;
    will-change: transform;
    transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);
    transform-style: preserve-3d;
    
}
 
.right {
    transform-origin: 100%;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, -8.33vw) rotateX(0) rotateY(90deg) rotateZ(0);
}
 
.top {
    transform-origin: 50% 0;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, -8.33vw) rotateX(90deg) rotateY(0) rotateZ(0);
}
 
.back {
    z-index: 2;
    transform-origin: 50%;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex
;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, -8.33vw);
}
 
.bottom {
    transform-origin: 50% 100%;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, -8.33vw) rotateX(-90deg) rotateY(0) rotateZ(0);
}
 
.left {
    transform-origin: 0%;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, -8.33vw) rotateX(0) rotateY(-90deg) rotateZ(0);
}
 
.front {
    z-index: 2;
    transform-style: preserve-3d;
    flex-flow: column;
    flex: none;
    justify-content: center;
    align-items: center;
    min-width: 22.2vw;
    max-width: 22.2vw;
    min-height: 22.2vw;
    max-height: 22.2vw;
    display: flex
;
    position: absolute;
    overflow: hidden;
    transform: translate3d(0, 0, 13.89vw);
}
 
</style>
3D Cube Effect JS Code
<script>
window.addEventListener('scroll', () => {
  const elements = document.querySelectorAll('.scrollText, .scrollIcon');
  const windowHeight = window.innerHeight;

  elements.forEach(el => {
    const rect = el.getBoundingClientRect();

    // Nested if instead of &&
    if (rect.top < windowHeight) {
      if (rect.bottom > 0) {
        const progress = Math.min(
          Math.max((windowHeight - rect.top) / (windowHeight * 0.5), 0),
          1
        );

        let xStart = 0;
        let yStart = 0;

        if (el.classList.contains('from-left')) {
          xStart = -20;
        } else if (el.classList.contains('from-right')) {
          xStart = 20;
        } else if (el.classList.contains('from-bottom')) {
          yStart = 10;
        }

        const xCurrent = xStart * (1 - progress);
        const yCurrent = yStart * (1 - progress);
        el.style.transform = `translate3d(${xCurrent}vw, ${yCurrent}vw, 0)`;
      } else {
        el.style.transform = `translate3d(0, 0, 0)`;
      }
    } else {
      el.style.transform = `translate3d(0, 0, 0)`;
    }
  });
});

const cube = document.getElementById("cube");
const section = document.getElementById("cube-section");

function getResponsivePhasePercentages() {
  const screenWidth = window.innerWidth;
  let transitionPercent, pausePercent;

  if (screenWidth < 640) { // Mobile
    transitionPercent = 0.1;
    pausePercent = 0.05;
  } else if (screenWidth < 1024) { // Tablet
    transitionPercent = 0.12;
    pausePercent = 0.07;
  } else { // Desktop
    transitionPercent = 0.15;
    pausePercent = 0.05;
  }

  return { transitionPercent, pausePercent };
}

function updateCubeTransform() {
  const { transitionPercent, pausePercent } = getResponsivePhasePercentages();
  const viewportHeight = window.innerHeight;
  const sectionRect = section.getBoundingClientRect();
  const sectionHeight = section.offsetHeight;

  // Nested ifs instead of &&
  let isSectionInView = false;
  if (sectionRect.top <= viewportHeight / 2) {
    if (sectionRect.top + sectionHeight >= viewportHeight / 2) {
      isSectionInView = true;
    }
  }

  if (!isSectionInView) {
    requestAnimationFrame(updateCubeTransform);
    return;
  }

  // Calculate scroll progress
  const totalScrollDistance = sectionHeight + viewportHeight;
  const scrollProgress = Math.min(
    Math.max((viewportHeight / 2 - sectionRect.top) / totalScrollDistance, 0),
    1
  );

  // Define rotation phases
  const phases = [
    // 1. Front → Right
    { end: transitionPercent, transform: p => `rotateY(${90 * p}deg)` },
    { end: transitionPercent + pausePercent, transform: () => `rotateY(90deg)` },

    // 2. Right → Top
    { end: 2 * transitionPercent + pausePercent, transform: p => `rotateY(${90 * (1 - p)}deg) rotateX(${90 * p}deg)` },
    { end: 2 * transitionPercent + 2 * pausePercent, transform: () => `rotateX(90deg)` },

    // 3. Top → Back
    { end: 3 * transitionPercent + 2 * pausePercent, transform: p => `rotateX(${90 * (1 - p)}deg) rotateY(${180 * p}deg)` },
    { end: 3 * transitionPercent + 3 * pausePercent, transform: () => `rotateY(180deg)` },

    // 4. Back → Bottom
    { end: 4 * transitionPercent + 3 * pausePercent, transform: p => `rotateY(${180 * (1 - p)}deg) rotateX(${-90 * p}deg)` },
    { end: 4 * transitionPercent + 4 * pausePercent, transform: () => `rotateX(-90deg)` }
  ];

  // Find current phase and apply transform
  let transform = "";
  let phaseStart = 0;

  for (const phase of phases) {
    if (scrollProgress <= phase.end) {
      const p = (scrollProgress - phaseStart) / (phase.end - phaseStart);
      transform = phase.transform(p);
      break;
    }
    phaseStart = phase.end;
  }

  cube.style.transform = transform;
  requestAnimationFrame(updateCubeTransform);
}

// Start animation
requestAnimationFrame(updateCubeTransform);

// Handle window resize
window.addEventListener('resize', () => {
  requestAnimationFrame(updateCubeTransform);
});
</script>
3D Cube Effect Style CSS Classes
services-card-text
scrollText
scrollIcon
cube-wrapper
box-cube
right
top
back
bottom
left
front
3D Cube Effect Style CSS ID
cube-section
cube

Get Your FREE Freelancing Roadmap

Stop hopping between tutorials. Grab the Freelancing Mastery Handbook to learn how to choose a skill, build your foundation, find clients, and confidently start your freelancing journey.

Free eBook Download

Related Tutorials

From learning the right skills to building a stronger digital presence, we help you turn ideas into practical, professional results.

Vibe Code a REAL Animated WordPress Website with Claude + Elementor

21.8K views

View Tutorial

Vibe Coding Full Course for Beginners – Build & Launch a Real SaaS

3.3K views

View Tutorial

Edit Videos with ChatGPT Codex — Raw Clips to Finished Reel

3.4K views

View Tutorial

Browse All Tutorials