Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
    <div class="hi">
        <div class="hi__cuboid">
            <div class="face face--front"><p class="hi__word">Hello</p></div>
            <div class="face face--back"><p class="hi__word">Hello</p></div>
            <div class="face face--top"><p class="hi__word">Hello</p></div>
            <div class="face face--bottom"><p class="hi__word">Hello</p></div>
        </div>
        <div class="hi__cuboid">
            <div class="face face--front"><p class="hi__word">From</p></div>
            <div class="face face--back"><p class="hi__word">From</p></div>
            <div class="face face--top"><p class="hi__word">From</p></div>
            <div class="face face--bottom"><p class="hi__word">From</p></div>
        </div>
        <div class="hi__cuboid">
            <div class="face face--front"><p class="hi__word">Dublin</p></div>
            <div class="face face--back"><p class="hi__word">Dublin</p></div>
            <div class="face face--top"><p class="hi__word">Dublin</p></div>
            <div class="face face--bottom"><p class="hi__word">Dublin</p></div>
        </div>
        
    </div> 
    <div class="hi__base">
        <div class="hi__base-plate"></div>
        <p class="hi__location hi__location--lat">53.3454° N</p>
        <p class="hi__location hi__location--long">-6.3070° E</p>
    </div>
</div>

<div class="collection">
    <a class="collection__link" href="http://type.bandeins.de/" target='_blank'>Get the font<span></span></a>
</div>

<a href="https://greensock.com" target="_blank"><img class="gsap-3-logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/gsap-3-logo.svg" width="150" /></a>
              
            
!

CSS

              
                @font-face {
    /* 
	Bandeins Strange 
	http://type.bandeins.de/
	This free font is for demonstration purposes only. You may not distribute, rent, sell, give away, publicly or privately share any modified or unmodified version of the font. Special permission has been granted to crosslink to it for demo purposes only. You must obtain an appropriate license at <http://type.bandeins.de/> before linking to this font or using it in any other context.
	*/
    font-family: 'Bandeins-Strange';
    src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/61488/BandeinsStrangeVariableGX.ttf') format('truetype');
    font-stretch: 100% 800%;
    font-weight: 200 800;
    font-display: block;
}

/*  ==========================================================
	MIXINS
	========================================================== */
	
@mixin cuboid($cWidth, $cHeight, $cDepth, $cColor) {
	position: relative;
	width: $cWidth;
	height: $cHeight;
	transform-style: preserve-3d;
	
	.face {
		position: absolute;
		left: 0;
		top: 0;
		background-color: $cColor;
	}
	
	.face--front {
		width: $cWidth;
		height: $cHeight;
		transform: translateZ(calc(#{$cDepth}/2));
	}

	.face--back {
		width: $cWidth;
		height: $cHeight;
		transform: translateZ(calc(#{$cDepth}/2 *-1)) rotateY(180deg) rotate(180deg);
	}

	.face--left {
		width: $cDepth;
		height: $cHeight;
		transform: translateX(calc(#{$cDepth}/2 *-1)) rotateY(-90deg);
	}

	.face--right {
		width: $cDepth;
		height: $cHeight;
		transform: translateX(calc(#{$cWidth} - #{$cDepth}/2)) rotateY(90deg);
	}

	.face--top {
		width: $cWidth;
		height: $cDepth;
		transform: translateY(calc(#{$cDepth}/2 * -1)) rotateX(90deg);
	}

	.face--bottom {
		width: $cWidth;
		height: $cDepth;
		transform: translateY(calc(#{$cHeight} - #{$cDepth}/2)) rotateX(-90deg);
	}
}

/*  ==========================================================
	MAIN
	========================================================== */

:root {
    --grey: #5E5D5E;
    --mid-grey: #3f3f3f;
}

html {
	box-sizing: border-box;
}

*, *:before, *:after {
	box-sizing: inherit;
}

html, body {
	width: 100%;
	height: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: black;
    font-family: 'Bandeins-Strange';
    color: white;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    background-size: 50px 50px;
    background-position: center;
    background-image:
        linear-gradient(to right, var(--mid-grey) 1px, transparent 1px),
        linear-gradient(to bottom, var(--mid-grey) 1px, transparent 1px);
}

.container {
	position: relative;
	width: 100%;
	height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 900px;
	visibility: hidden;
}

.hi {
    position: relative;
    z-index: 1;
    font-size: 100px;
    font-stretch: 400%;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    text-align: center;
    transform-style: preserve-3d;
}

.hi__cuboid {
    @include cuboid(500px, 70px, 70px, black);
    margin: 30px 0;
}

.face {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    &.face--top, &.face--bottom {
        background: white;
        color: black;
    }
}

.hi__word {
    margin: 0;
    transform: translateY(-5px);
}

.hi__base {
    position: absolute;
    z-index: 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 752px;
    height: 250px;
}

.hi__base-plate {
    width: 100%;
    height: 100%;
    background: black;
    border: 1px solid var(--grey);
}

.hi__location {
    position: absolute;
    margin: 0;
    font-size: 20px;
    font-stretch: 400%;
    font-weight: 400;
}

.hi__location--lat {
    top: 50%;
    left: 0vw;
    transform: rotate(-90deg) translateX(10px);
}

.hi__location--long {
    top: 50%;
    right: 0vw;
    transform: rotate(90deg) translateX(-10px);
}

.gsap-3-logo {
    width: 20vw;
    max-width: 150px;
    position: fixed;
    bottom: 15px;
    right: 15px;
}

/*  ==========================================================
    Font Link
    ========================================================== */

.collection {
    position: fixed;
    z-index: 1000;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
}

.collection__link {
    position: relative;
    margin-bottom: 16px;
    color: white;
    text-decoration: none;
    font-size: 16px;

    span {
        display: block;
        position: absolute;
        bottom: -3px;
        left: 0;
        height: 1px;
        width: 10%;
        background-color: white;
        content: "";
        transition: width 0.3s;
    }

    &:hover {
        text-decoration: none;
        span{
            width: 100%;
        }
    }
}
              
            
!

JS

              
                console.clear();

select = e => document.querySelector(e);
selectAll = e => document.querySelectorAll(e);

const container = select('.container');
const cuboid = selectAll('.hi__cuboid');
const hiWords = selectAll('.hi__word');
const base = select('.hi__base-plate');
let winW = 0;
let winH = 0;
let pointer = { 
	x: window.innerWidth / 2, 
	y: window.innerHeight / 2 
};

function init() {
    
    setWinDimensions();

    gsap.set(container, { autoAlpha: 1 });
    
    gsap.timeline({ delay: 0.5 })
        .from('.hi__location--lat', {
            x: 100,
            autoAlpha: 0,
            ease: 'power4',
            duration: 1
        })
        .from('.hi__location--long', {
            x: -100,
            autoAlpha: 0,
            ease: 'power4',
            duration: 1
        }, 0)
        .from(cuboid, {
            y: winH,
            duration: 3,
            stagger: 0.14,
            ease: 'elastic(0.4,0.3)'
        }, 0);
    
    gsap.to(cuboid, { 
        rotateX: -360, 
        duration: 8, 
        repeat: -1, 
        ease: 'none' 
    });
    
    gsap.fromTo(cuboid, { 
        rotateY: 8, 
        rotate: -10 
    },{ 
        rotateY: -8, 
        rotate: 10,
        duration: 2.2, 
        yoyo: true, 
        repeat: -1, 
        ease: 'sine.inOut' 
    });
}

function setWinDimensions() {
    winW = window.innerWidth;
    winH = window.innerHeight;
}

function calcOffset(xPos, yPos) {
	let dX = 2*(xPos - winW/2)/winW;
	let dY = -2*(yPos - winH/2)/winH;
	return [dX,dY];
}

function followPointer(pX, pY) {
    let nPos = calcOffset(pX, pY); // get cursor position from center
    let nX = nPos[0];
	let nY = nPos[1];
    let positiveX = Math.sqrt(nX*nX);
	let positiveY = Math.sqrt(nY*nY);
    let deltaS = 450*positiveX;
    let deltaW = 600*positiveY;
	gsap.to(hiWords, {
		fontStretch: `${(550-deltaS)}%`,
        fontWeight: 800-deltaW,
		duration: 2
	});
}

window.addEventListener("mousemove", function(event) {
	pointer.x = event.clientX;
	pointer.y = event.clientY;
	followPointer(pointer.x, pointer.y);
});

window.addEventListener('touchmove', function(event) {
 	pointer.x = event.touches[0].clientX;
  	pointer.y = event.touches[0].clientY;
	followPointer(pointer.x, pointer.y);
});

window.addEventListener('touchstart', function(event) {
 	pointer.x = event.touches[0].clientX;
  	pointer.y = event.touches[0].clientY;
	followPointer(pointer.x, pointer.y);
});

window.onload = () => {
	init();
};

window.onresize = setWinDimensions;
              
            
!
999px

Console