css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="overlay"></div>
<div class="title">
  <h1>GSAP SplitText Utility</h1>
  <div class="container alice-text">
  The Hatter opened his eyes very wide on hearing this; but all he said was, &ldquo;Why is a raven like a writing-desk?&rdquo; <br><br>
  &ldquo;Come, we shall have some fun now!&rdquo; thought Alice. &ldquo;I’m glad they’ve begun asking riddles. &mdash; I believe I can guess that,&rdquo; she added aloud.

              $main-color: rgba(221, 146, 221, .8);
* {
  box-sizing: border-box;

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/aliceinwonderland.jpg) top center no-repeat;
  background-size: cover;

  text-align: center;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: 0;
  padding: 0;
  background-color: darken($main-color, 40);
  z-index: 1;

.title {
  margin: 0;
  margin-bottom: 1em;
  padding: 0;
  position: relative;
  z-index: 2;
  h1 {
    margin: 0;
    padding: 0.5em;
    color: white;
    font-size: 2rem;
    font-weight: 300;

.container {
	transform: translate3d(0, 0, 0);
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: auto;
  max-width: 600px;
  min-width: 300px;
  margin: 0 auto;
  padding: 1em;
  color: white;
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  line-height: 1.5;
  border-radius: 15px;
  z-index: 2;
  @media (min-width: 650px) {
    margin-top: 1em;  

              // vars
const aliceText = document.querySelector('.alice-text'),
      textTypes = new SplitText(aliceText, {
        type: 'lines, words' //split into lines and words
      linesLength = textTypes.lines.length,
      wordsLength = textTypes.words.length,
      button = document.querySelector('.btn'),
      tl = new TimelineMax();

// Prep the quote div for 3D 
TweenMax.set(aliceText, {transformPerspective:600, perspective:300, transformStyle:'preserve-3d', autoAlpha:1});

// rotate each line using random values
for(let i = 0; i < linesLength; i++) {
    .from(textTypes.lines[i], 1, {
    z: randomNumber(-100, 50),
    rotation: randomNumber(-360, 360),
    rotationX: randomNumber(-360, 360),
    rotationY: 90,
    opacity: 0,
    transformOrigin: '50% 75% 200',
    ease: Circ.easeInOut
  }, Math.random()*1.5);

// Rotate each word using some random values
for(let i = 0; i < wordsLength; i++) {
    .to(textTypes.words[i], 0.5, {
    opacity: 0,
    z: randomNumber(-100, 500),
    rotation: randomNumber(360, 720),
    rotationX: randomNumber(-360, 360),
    rotationY: randomNumber(-360, 360)
  }, 'sentenceEntrance-=' + Math.random() * 0.2);

// Set each word to the original position (no rotation)
for(let i = 0; i < wordsLength; i++) {
    .to(textTypes.words[i], 0.5, {
    opacity: 1,
    z: 0,
    x: 0,
    y: 0,
    rotation: 0,
    rotationX: 0,
    rotationY: 0,
    onComplete: function() {
      // This removes all the extra markup that SplitText 
      // adds to the DOM thereby cleaning up after the 
      // animation is done
  }, 'vanish-=' + Math.random() * 0.2);

// Helper function you can find on GSAP demos 
// to randomize values, which I used above
function randomNumber(min, max){
	return Math.floor(Math.random() * (1 + max - min) + min);

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................