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="wrap">
<!--   <button class="toast-btn">Make a toast</button> -->
  <div class="toast">
    <div class="container open">
      <div class="msg">
        <span class="error-msg main-msg">Please resolve  
          <span class="error-num"></span> 
          errors in order to submit your document
        </span>
        <span class="error-msg">Something bad happened here</span>
        <span class="error-msg">An error occurred there</span>
        <span class="error-msg">Something bad happened everywhere</span>
        <span class="error-msg">A bad thing happened, it should be fixed</span>
        <span class="error-msg">Something bad definitely happened</span>
      </div>
    </div>
    <i class="fas fa-chevron-down icon open"></i>
  </div>
  <div class="orderset">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod sit amet justo ut dignissim. In rhoncus nunc et nulla mollis egestas. Vestibulum sit amet libero sollicitudin, lacinia lacus vel, pulvinar eros. Ut mollis eros id nibh finibus consectetur. Donec condimentum ligula eget efficitur fermentum. Donec at varius purus, sagittis ullamcorper dolor. Fusce aliquet mi et nulla faucibus tincidunt. Vestibulum scelerisque turpis a venenatis aliquam. Maecenas fermentum leo nisi, eget pretium sem maximus a. Praesent tristique mi porttitor, molestie sem vitae, pellentesque dui. Duis imperdiet sapien mattis ex interdum, quis pellentesque magna malesuada. Maecenas dignissim arcu orci, nec vehicula tellus hendrerit non. Quisque pretium metus non massa imperdiet, ut egestas ante hendrerit. Aenean mollis blandit arcu, id faucibus lorem porttitor fringilla. Nulla pellentesque tempor mi tempor maximus. Duis non porttitor purus.</p>
  <p>Proin sem dolor, malesuada sit amet felis at, pellentesque volutpat felis. Pellentesque fringilla erat a mauris blandit maximus. Cras vel tellus nec felis vulputate elementum non non arcu. Suspendisse condimentum metus a arcu condimentum venenatis. Mauris hendrerit massa et dui consectetur ultricies. Praesent velit metus, luctus imperdiet ornare et, consectetur id massa. Quisque malesuada tortor ex, quis tincidunt dolor lacinia nec. Fusce dapibus lacinia arcu, vel tincidunt dolor congue at. Nullam a condimentum turpis, tincidunt congue purus. Nunc faucibus, nunc vitae porttitor efficitur, nisl nibh euismod quam, mattis hendrerit ex mauris ac turpis. Vivamus consequat enim sed faucibus iaculis.</p>
  <p>Aliquam et mi eget turpis pellentesque finibus. Curabitur ut sapien blandit, dignissim ipsum a, mattis nibh. Nulla in lectus eu metus cursus mattis. In ut dolor id neque blandit commodo. Aenean in eleifend elit, ut fringilla velit. Morbi a molestie orci. Etiam et ullamcorper purus. Donec id imperdiet risus, ut porttitor lacus. Vestibulum eu molestie turpis. Aenean tincidunt dapibus maximus. Nulla nec malesuada leo.</p>
  <p>Pellentesque libero leo, bibendum vel efficitur vel, consectetur at mi. Pellentesque ornare turpis vitae neque suscipit, id molestie sapien interdum. Nulla volutpat malesuada vulputate. Fusce pulvinar egestas tellus quis sodales. Sed nec ullamcorper metus. Suspendisse at dapibus tellus. Suspendisse potenti.</p>
  <p>Vestibulum purus enim, imperdiet a lorem non, lacinia ornare sapien. Nam id nisi magna. Aliquam cursus diam vel tempus scelerisque. Etiam vitae nibh velit. Vestibulum mauris purus, dapibus sed tincidunt id, ultrices ac ex. Nunc eget nulla consequat, viverra nisl quis, mattis velit. Sed sit amet rhoncus quam. Nullam vitae velit semper, interdum justo in, luctus urna. In pellentesque vel orci pellentesque viverra.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod sit amet justo ut dignissim. In rhoncus nunc et nulla mollis egestas. Vestibulum sit amet libero sollicitudin, lacinia lacus vel, pulvinar eros. Ut mollis eros id nibh finibus consectetur. Donec condimentum ligula eget efficitur fermentum. Donec at varius purus, sagittis ullamcorper dolor. Fusce aliquet mi et nulla faucibus tincidunt. Vestibulum scelerisque turpis a venenatis aliquam. Maecenas fermentum leo nisi, eget pretium sem maximus a. Praesent tristique mi porttitor, molestie sem vitae, pellentesque dui. Duis imperdiet sapien mattis ex interdum, quis pellentesque magna malesuada. Maecenas dignissim arcu orci, nec vehicula tellus hendrerit non. Quisque pretium metus non massa imperdiet, ut egestas ante hendrerit. Aenean mollis blandit arcu, id faucibus lorem porttitor fringilla. Nulla pellentesque tempor mi tempor maximus. Duis non porttitor purus.</p>
  <p>Proin sem dolor, malesuada sit amet felis at, pellentesque volutpat felis. Pellentesque fringilla erat a mauris blandit maximus. Cras vel tellus nec felis vulputate elementum non non arcu. Suspendisse condimentum metus a arcu condimentum venenatis. Mauris hendrerit massa et dui consectetur ultricies. Praesent velit metus, luctus imperdiet ornare et, consectetur id massa. Quisque malesuada tortor ex, quis tincidunt dolor lacinia nec. Fusce dapibus lacinia arcu, vel tincidunt dolor congue at. Nullam a condimentum turpis, tincidunt congue purus. Nunc faucibus, nunc vitae porttitor efficitur, nisl nibh euismod quam, mattis hendrerit ex mauris ac turpis. Vivamus consequat enim sed faucibus iaculis.</p>
  <p>Aliquam et mi eget turpis pellentesque finibus. Curabitur ut sapien blandit, dignissim ipsum a, mattis nibh. Nulla in lectus eu metus cursus mattis. In ut dolor id neque blandit commodo. Aenean in eleifend elit, ut fringilla velit. Morbi a molestie orci. Etiam et ullamcorper purus. Donec id imperdiet risus, ut porttitor lacus. Vestibulum eu molestie turpis. Aenean tincidunt dapibus maximus. Nulla nec malesuada leo.</p>
  <p>Pellentesque libero leo, bibendum vel efficitur vel, consectetur at mi. Pellentesque ornare turpis vitae neque suscipit, id molestie sapien interdum. Nulla volutpat malesuada vulputate. Fusce pulvinar egestas tellus quis sodales. Sed nec ullamcorper metus. Suspendisse at dapibus tellus. Suspendisse potenti.</p>
  <p>Vestibulum purus enim, imperdiet a lorem non, lacinia ornare sapien. Nam id nisi magna. Aliquam cursus diam vel tempus scelerisque. Etiam vitae nibh velit. Vestibulum mauris purus, dapibus sed tincidunt id, ultrices ac ex. Nunc eget nulla consequat, viverra nisl quis, mattis velit. Sed sit amet rhoncus quam. Nullam vitae velit semper, interdum justo in, luctus urna. In pellentesque vel orci pellentesque viverra.</p>
</div>
</div>
<!-- <div class="orderset">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod sit amet justo ut dignissim. In rhoncus nunc et nulla mollis egestas. Vestibulum sit amet libero sollicitudin, lacinia lacus vel, pulvinar eros. Ut mollis eros id nibh finibus consectetur. Donec condimentum ligula eget efficitur fermentum. Donec at varius purus, sagittis ullamcorper dolor. Fusce aliquet mi et nulla faucibus tincidunt. Vestibulum scelerisque turpis a venenatis aliquam. Maecenas fermentum leo nisi, eget pretium sem maximus a. Praesent tristique mi porttitor, molestie sem vitae, pellentesque dui. Duis imperdiet sapien mattis ex interdum, quis pellentesque magna malesuada. Maecenas dignissim arcu orci, nec vehicula tellus hendrerit non. Quisque pretium metus non massa imperdiet, ut egestas ante hendrerit. Aenean mollis blandit arcu, id faucibus lorem porttitor fringilla. Nulla pellentesque tempor mi tempor maximus. Duis non porttitor purus.</p>
  <p>Proin sem dolor, malesuada sit amet felis at, pellentesque volutpat felis. Pellentesque fringilla erat a mauris blandit maximus. Cras vel tellus nec felis vulputate elementum non non arcu. Suspendisse condimentum metus a arcu condimentum venenatis. Mauris hendrerit massa et dui consectetur ultricies. Praesent velit metus, luctus imperdiet ornare et, consectetur id massa. Quisque malesuada tortor ex, quis tincidunt dolor lacinia nec. Fusce dapibus lacinia arcu, vel tincidunt dolor congue at. Nullam a condimentum turpis, tincidunt congue purus. Nunc faucibus, nunc vitae porttitor efficitur, nisl nibh euismod quam, mattis hendrerit ex mauris ac turpis. Vivamus consequat enim sed faucibus iaculis.</p>
  <p>Aliquam et mi eget turpis pellentesque finibus. Curabitur ut sapien blandit, dignissim ipsum a, mattis nibh. Nulla in lectus eu metus cursus mattis. In ut dolor id neque blandit commodo. Aenean in eleifend elit, ut fringilla velit. Morbi a molestie orci. Etiam et ullamcorper purus. Donec id imperdiet risus, ut porttitor lacus. Vestibulum eu molestie turpis. Aenean tincidunt dapibus maximus. Nulla nec malesuada leo.</p>
  <p>Pellentesque libero leo, bibendum vel efficitur vel, consectetur at mi. Pellentesque ornare turpis vitae neque suscipit, id molestie sapien interdum. Nulla volutpat malesuada vulputate. Fusce pulvinar egestas tellus quis sodales. Sed nec ullamcorper metus. Suspendisse at dapibus tellus. Suspendisse potenti.</p>
  <p>Vestibulum purus enim, imperdiet a lorem non, lacinia ornare sapien. Nam id nisi magna. Aliquam cursus diam vel tempus scelerisque. Etiam vitae nibh velit. Vestibulum mauris purus, dapibus sed tincidunt id, ultrices ac ex. Nunc eget nulla consequat, viverra nisl quis, mattis velit. Sed sit amet rhoncus quam. Nullam vitae velit semper, interdum justo in, luctus urna. In pellentesque vel orci pellentesque viverra.</p>
</div> -->

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
              
            
!

CSS

              
                html, body {
  height: 100%;
}

body {
  display: flex;
  flex-wrap: wrap;
  align-items: top;
  justify-content: center;
  background: #fff;
  font-family: "PT Sans";
  color: #212121;
  padding-top: 20px;
  font-family: 'Helvetica';
}
.orderset {
  width: 920px;
  padding: 16px;
  border: 3px solid #727272;
  margin: 16px auto;
  p {
    margin-bottom: 24px;
  }
}
.toast {
  width: 80vw;
  min-height: 2em;
  border-radius: 3px;
  padding: 8px;
  background-color: #ffeaea;
  border: 1px solid rgb(255,0,0);
  display: flex;
  align-items: top;
  position: sticky;
  top: 20px;
  z-index: 2;
  margin: 0 auto;
  .container {
    display: flex;
    flex: 1;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 650ms ease-in-out;
    padding: 8px;
    &.close {
      max-height: 16px;
      &.msg {
        display: none;
      }
    }
    .msg {
      flex: 1;
      flex-wrap: wrap;
      color: #ff0000;
      font-size: 1em;
      display: flex;
      .error-msg {
        display: flex;
        flex-grow:1;
        flex-basis: 100%;
        justify-content: center;
        opacity: 1;
        transition: opacity 300ms, height 300ms;
        height: 22px;
        &.main-msg {
          // opacity: 0;
          height: 40px;
          color: #555555;
          font-weight: bold;
        }
      }
    }
  }
  .fas {
    color: #555555;
    display: flex;
    width: 60px;
    flex: 0;
    padding: 8px;
    transition: all 300ms;
    height: 14px;
    transform-origin: 50% 50%;
    &.close {
      transform: rotate(180deg);
    }
  }
}



              
            
!

JS

              
                const closeBtn = document.querySelector('.icon');
const container = document.querySelector('.container');
let errs = document.querySelector('.msg').childElementCount;
let errNum = document.querySelector('.error-num');

let errTotal = errs - 1;
console.log(errNum);
console.log(errTotal);

const displayErrorTotal = `
 <span class="number">\u00A0${errTotal}\u00A0</span>
`;

errNum.innerHTML = displayErrorTotal;

closeBtn.addEventListener('click', function(){
  // alert('clicked');
  let first = 'close';
  let second = 'open';
  if(container.classList.contains(first)) {
    [first, second] = [second, first]
  }
  //if open, switch order of toggle!
  container.classList.toggle(first);
  container.classList.toggle(second);
  closeBtn.classList.toggle(first);
  closeBtn.classList.toggle(second);
});















// /*
//   NOTE: Babel is enabled, which translates much of the below to ES5 compatible code.
//   https://github.com/google/traceur-compiler
  
//   An alternative is 6to5: https://6to5.org/
  
//   Helpful docs for getting up to speed on ES6: https://6to5.org/docs/learn-es6/
// */

// // Convenience function for logging. Look funny? It won't by the end of this.
// let _ = msg => console.log(msg);

// /*
//  * let is the new var
//  */
// let someVariable = 'some value';
// _(someVariable); // some value

// // Value is mutable
// someVariable = 'another value';
// _(someVariable); // another value

// // This would cause an error, cannot redeclare in the same block/scope.
// // let someVariable = 'yet another value';

// // This is OK, as it's a different block/scope.
// function something() {
//   let someVariable = 'yet another value';
//   // do stuff
// }

// /*
//  * Constants
//  * Cannot be changed once they are set.
//  */
// const a = 'Some string';
// // The following line would generate an error. 'a' is read only.
// // a = 'Another string';

// /*
//  * Template strings
//  */
// let firstName = 'Brad';
// let lastName = 'Daily';

// _(`My name is ${firstName} ${lastName}.`); // My name is Brad Daily.

// // Can be multiline too
// let multilineString = `My name is ${firstName} ${lastName}.
// Really nice to meet ya.`;

// _(multilineString); // My name is Brad Daily.\nReally nice to meet ya.

// /*
//  * 'Spread' operator
//  * Creates an array from all passed arguments
//  */
// let spread = function(...x) {
//   return x;
// }

// _(spread(1, 2, 3)); // [1, 2, 3]

// /*
//  * Fat arrow function syntax
//  */

// /* Old way

//   var helloWorld = function() {
//     return 'Hello world';
//   }
// */

// let helloWorld = () => 'Hello world.';

// _(helloWorld()); // Hello world.

// // Here's that spread function from earlier
// let newSpread = (...x) => x;

// _(newSpread(3, 4, 5)); // [3, 4, 5]

// // Example using spread operator plus arrow functions.
// // add()  will sum any numbers passed to it as arguments.
// let add = (...x) => x.reduce((previous, current) => previous + current);
// _(add(1, 5, 10, 20)); // 36

// // Array sort
// _([1, 5, 8, 2, 3, 4].sort((a, b) => a < b ? -1 : 1)); // [1, 2, 3, 4, 5, 8]

// // Arrow functions inherit the scope they are defined in.
// // No more var self = this;
// // See: this.owner in the sayFruits function
// let pantry = {
//   owner: 'Jim',
//   fruits: ['apple', 'orange', 'pear'],
//   sayFruits() {
//     this.fruits.forEach(fruit => {
//       _(`${this.owner}'s pantry has ${fruit}s`);
//     });
//   }
// }

// pantry.sayFruits();
// // Jim's pantry has apples
// // Jim's pantry has oranges
// // Jim's pantry has pears

// /*
//  * Object literals
//  */
// let x = 50;
// let y = 100;

// /* Old way

//   var coordinates = {
//     x: x,
//     y: y
//   }
  
// */

// let coordinates = {
//   x, y
// };

// _(coordinates); // Object { x: 50, y: 100}

// /*
//  * Destructuring
//  */
// let http = () => [404, 'Not found'];
// let [status, textResponse] = http();

// _(status); // 404
// _(textResponse); // Not found

// /*
//  * Classes
//  */
// class Person {
//   constructor(firstName, lastName, age) {
//     this.firstName = firstName;
//     this.lastName = lastName;
//     this.age = age;
//   }
  
//   // Getters allow for dynamic properties
//   // In this example, you can use .fullName instead of .fullName()
//   // See the greeting() function below 
//   get fullName() {
//     return `${this.firstName} ${this.lastName}`;
//   }
  
//   greeting() {
//     return `Hi, my name is ${this.fullName} and I am ${this.age} years old.`; 
//   }
  
//   isAdult() {
//     return this.age >= 18;
//   }
// }

// let me = new Person('Brad', 'Daily', 35);
// _(me.isAdult()); // true
// _(me.greeting()); // Hi, my name is Brad Daily and I am 35 years old.
// me.age = 36;
// _(me.greeting()); // Hi, my name is Brad Daily and I am 36 years old.

// // Class extension
// class Pirate extends Person {
//   greeting() {
//     return `Arggh, me name is ${this.fullName} and I've been sailing these here seas for ${this.age} years.`;  
//   }
// }

// var pirate = new Pirate('Brad', 'Daily', 35);
// _(pirate.greeting()); // Arggh, me name is Brad Daily and I've been sailing these here seas for 35 years.

// /*
//  * Default parameters values
//  */
// function repeat(toldYa = 'Nothin') {
//   return `You told me ${toldYa}.`;
// }

// _(repeat()); // You told me Nothin'.
// _(repeat("Somethin'")); // You told me Somethin'.

// // Arrow version
// let repeat2 = (toldYa = "Nothin'") => `You told me ${toldYa}.`;

// _(repeat2()); // You told me Nothin'.
// _(repeat2("Somethin'")); // You told me Somethin'.

// /*
//  * Sets
//  */
// let letters = new Set();
// letters.add('A');
// _(letters.size); // 1

// // Ignores duplicate values
// letters.add('A');
// _(letters.size); // 1

// _(letters.has('A')); // true
// _(letters.has('B')); // false

// letters.add('B');

// for (let letter of letters) _(letter); // Outputs A, then B

// _(letters.delete('Z')); // returns false since Z is was not in letters before delete()
// _(letters.delete('A')); // returns true since A is was in letters before delete()

// letters.clear();
// _(letters.size); // 0

// /*
//  * Maps
//  */
// let map = new Map();
// map.set('string-key', 'I belong to the string-key');

// // Keys can be anything, like a DOM element
// map.set(document.getElementsByTagName('h1')[0], 'I belong to the first <h1> in the DOM.');

// _(map.size); // 2

// _(map.get(document.getElementsByTagName('h1')[0])); // I belong to the first <h1> in the DOM.

// for (let [key, val] of map.entries()) {
//   _(key); // Outputs 'string-key', then the <h1>
//   _(val); // Outputs 'I belong to the string-key', then 'I belong to the first <h1> in the DOM.'
// }
              
            
!
999px

Console