Pen Settings

HTML

CSS

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

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

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.

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

              
                <!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta charset="utf-8">
    <title>Making Stuffs</title>
    <link rel="stylesheet" href="./assets/css/style.css">
    <script src="./assets/js/head-scripts.js" charset="utf-8" defer></script>
  </head>
  <body>
    <header id='intro'>
      <div class='intro-box'>
        <h1 id='welcome-text'>
          Hi
        </h1>
        <span id='text-1'>
          My name is Paul.
        </span>
        <span id='text-2'>
          And I like to make... 
        </span>
        <p id='intro-text'>
        </p>
      </div>
    </header>
    <main id='main'>
      <section id='about'>
      </section>
      <section id='skills'>
      </section>
      <section id='portfolio'>
      </section>
      <section id='contact'>
      </section>
    </main>
    <footer id='footer'>
    </footer>
  </body>
</html>

              
            
!

CSS

              
                :root {
  --ms-lighter: #FCFFFE;
  --ms-light: #DDFFF7;
  --ms-midLight: #93E1D8;
  --ms-mid: #FFA69E;
  --ms-midDark: #AA4465;
  --ms-dark: #861657;
  --ms-darker: #281F24;
  }
* {
  box-sizing: border-box;
}
html {
  font-size: 62.5%;
  scroll-behavior: smooth;
  background-color: var(--ms-darker);
  font-family: sans-serif;
}
body {
  overflow: auto;
  margin: 0;
}
header {
  min-height: 100vh;
  min-width: 100vw;
  background-color: var(--ms-dark);
  overflow: auto;
}
header > .intro-box {
  height:40vh;
  width:50vw;
  top:30vh;
  left:25vw;
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  color:var(--ms-light);
}
header > .intro-box > h1 {
  font-size: 4rem;
  margin: 0;
  position: absolute;
  text-align: center;
  width: 100%;
}
header > .intro-box > p {
  font-size: 2rem;
  margin: 0;
}
#text-1, #text-2 {
  position: absolute;
  font-size: 4rem;
  display: none;
}

              
            
!

JS

              
                
// Make some basic functions to save time.
const query = (elem) => {
  return document.querySelector(elem);
};
const queryAll = (elem) => {
  return document.querySelector(elem);
};
const createElem = (elem) => {
  return document.createElement(elem);
}
// Get the header element.
const header = query('header');
// Get our h1 element.
let h1 = query('h1');
// Get the intro text element
const intro = query('#intro-text');
const myNameIs = query('#text-1');
const andIMake = query('#text-2');

/*
  To create a web animation in the new web animation javscript API it is required
  that you first make an object which corresponds to a CSS keyframes block. This
  means it will need to have the parameters you would pass to a CSS transform or
  alike.

  It is essentially a matter of taking each stage of the keyframe - the 'from'
  'to' bit, and them putting each stages changed CSS into an element. You do not
  need to add the steps of change as javascript will work it out.

  This means if we pass a keyframe with three objects javascript will split it
  into three animations which will see the middle key activate half way through
  the animation and the first one at 0% while the last is at 100%. This is
  unless intstructed to do otherwise. You can specify the offset of each keyframe
  by providing an offset key value pair. For example, offset: 0.3 would mean
  the affects in that section would be applied at 30% completion regardless of
  the order which it was found by javascript. If you have less than two keyframes
  you will get an error.

  // ALICE TUMBLING EXAMPLE FROM MDN

  var aliceTumbling = [
    { transform: 'rotate(0) translate3D(-50%, -50%, 0)', color: '#000' },
    { color: '#431236', offset: 0.3},
    { transform: 'rotate(360deg) translate3D(-50%, -50%, 0)', color: '#000' }
  ];

  The next step is to create an object which houses the timing functions of the
  animation. This is read as AnimationEffectTimingProperties by the browser.

  // ALICE TUMBLING EXAMPLE

  var aliceTiming = {
    duration: 3000,
    iterations: Infinity
  }

  Duration must be in milliseconds and javascript uses 'iterations' instead of
  CSS's 'interation-count'

  In order to apply the styles you simply need to appenf 'animate' on the element
  and pass your arguments as objects.

*/

const fade = (a = 0, b = 1) => {
  return [
    { opacity: a },
    { opacity: b }
  ];
}
const glideX = (a = '-10000px', b = '0px') => {
  return [
    { transform: `translateX(${a})`, position: 'absolute' },
    { display: 'block', offset:0.1 },
    { transform: `translateX(${b})`, position: 'unset' }
  ];
}
const glideY = (a = '-10000px', b = '0px') => {
  return [
    { transform: `translateY(${a})`, position: 'absolute' },
    { display: 'block', offset:0.1 },
    { transform: `translateY(${b})`, position: 'unset' }
  ];
}
const animateSettings = (dur = 1500, it = 1, fill = 'forwards', ease = 'ease-in-out') => {
  return {
    duration: 1500,
    iterations: 1,
    fill: 'forwards',
    easing: 'ease-in-out'
  };
}
const start = h1.animate( fade(), animateSettings() );
start.onfinish = () => {
  myNameIs.style.display = 'block';
  const nameIn = myNameIs.animate( glideX(), animateSettings() );
  nameIn.onfinish = () => {
    const welcomeGo = h1.animate ( glideY( '0px', '10000px' ), animateSettings() );
    welcomeGo.onfinish = () => {
      h1.style.display = 'none';
      console.log('all done');
    }
  }
}

              
            
!
999px

Console