cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="container">
    <div class="cube cube--1">
        <div class="side side--back">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--left">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--right">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--top">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--bottom">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--front">
            <div class="side side--inner"></div>
        </div>
    </div>
    
    <div class="cube cube--2">
        <div class="side side--back">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--left">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--right">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--top">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--bottom">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--front">
            <div class="side side--inner"></div>
        </div>
    </div>
    
    <div class="cube cube--3">
        <div class="side side--back">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--left">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--right">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--top">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--bottom">
            <div class="side side--inner"></div>
        </div>
        <div class="side side--front">
            <div class="side side--inner"></div>
        </div>
    </div>
</div>
            
          
!
            
              $side: 3em;
$half-side: $side/2;

$pipe-width: 2.5em;
$pipe-height: 15em;
$pipe-offset: ($side - $pipe-width)/2;

$depth: 2em;
$shadow-width: 2em;

BODY {
    perspective: 1000px;
    perspective-origin: center center;
    overflow: hidden;
    font-size: 14px;
    background: #000;
    background-image: linear-gradient(
        to right,
        hsla(0, 0%, 100%, .025) 50%,
        transparent 30%
    );
    background-size: 2rem 100%;
}

.container {
    width: $side;
    height: $side;
    transform-style: preserve-3d;
    animation: rotate 12s infinite linear;
}

.cube {
    position: absolute;
    width: $side;
    height: $side;
    // outline: 2px solid gold;
    transform-style: preserve-3d;
    
    &--2 {
        transform: rotateX(45deg) rotateY(45deg);
    }
    &--3 {
        transform: rotateX(45deg) rotateZ(45deg);
    }
}

.side {
    position: absolute;
    width: $side;
    height: $side;
    // border: 2px dotted gold;
    background: #000;
    border-radius: 50%;
    
    transform-style: preserve-3d;
    
    &--inner {
        transform: rotateZ(90deg);
    }
    
    &::before, 
    &::after {
        content: "";
        display: block;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        top: 0;
        margin: auto;
        width: $pipe-width;
        height: $pipe-height;
        box-sizing: border-box;
        // border: 1px solid;
        animation: bg-size 10s infinite;
        
        background-image: linear-gradient(to bottom, 
            transparent, black, purple, 
            crimson, orangered, gold, 
            yellowgreen, teal, indigo,
            transparent
        );
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 300' preserveAspectRatio='none'%3E%3Cpath d='M0,0 100,300 200,0'%3E%3C/path%3E%3C/svg%3E");
    }
    
    &::before {
        margin-top: $pipe-offset;
        transform-origin: center top;
        transform: rotateX(85deg);
        color: gold;
    }
    &::after {
        margin-bottom: $pipe-offset;
        transform-origin: center bottom;
        transform: rotateX(95deg) translateY(100%);
        color: teal;
    }
}


.side--back {
    transform: translateZ(-$half-side) rotateY(180deg);
}

.side--left {
    transform: translateX(-$half-side) rotateY(-90deg);
}

.side--right {
    transform: translateX($half-side) rotateY(90deg);
}

.side--top {
    transform: translateY(-$half-side) rotateX(90deg);
}

.side--bottom {
    transform: translateY($half-side) rotateX(-90deg);
}

.side--front {
    transform: translateZ($half-side);
}

@keyframes rotate {
    100% {
        transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
    }
}

@keyframes bg-size {
    0% {
        background-size: 100% 120%;
        background-position: 0 50%;
    }
    50% {
        background-size: 100% 35%;
        background-position: 0 -50%;
    }
    100% {
        background-size: 100% 120%;
        background-position: 0 50%;
    }
}

// Helpers

HTML, BODY {
    height: 100%;
}

BODY {
    display: flex;
    justify-content: center;
    align-items: center;
}

            
          
!
999px
Loading ..................

Console