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

              
                - var banners = [{ icon: 'alert-circle-outline', class: 'error', message: 'Oops! Something went wrong!' }, {icon: 'checkmark-circle-outline', class:'success', message: 'Everything was fine!'},{icon: 'info-outline', class:'info', message: 'Here is some useful information'}];

.banners-container
  .banners
    each banner in banners
      .banner(class=banner.class)
        .banner-icon
          i(
            data-eva=banner.icon,
            data-eva-fill="#ffffff",
            data-eva-height="48",
            data-eva-width="48"
          )
        .banner-message= banner.message
        .banner-close(onclick="hideBanners()")
          i(data-eva="close-outline", data-eva-fill="#ffffff")

button.show-banner(onclick="showBanner('.banner.error')") Show Error
button.show-banner(onclick="showBanner('.banner.success')") Show Success
button.show-banner(onclick="showBanner('.banner.info')") Show Info

script(src="https://unpkg.com/eva-icons", onload="eva.replace()")

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");

$overshoot: 10%;
$color-error: #ed1c24;
$color-success: #10c15c;
$color-info: #0b22e2;

:root {
  font-family: "Montserrat";
}

html,
body {
  margin: 0;
  height: 100%;
}

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

i {
  color: inherit;
}

.banners-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

.banner {
  color: white;
  font-weight: 700;
  padding: 2rem;
  display: flex;
  flex-direction: row;
  align-items: center;

  .banner-message {
    flex: 1;
    padding: 0 2rem;
  }

  .banner-close {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;

    &:hover {
      background: rgba(0, 0, 0, 0.12);
    }
  }
}

@mixin banner($background) {
  background: $background;
  &::after {
    background: $background;
  }
}

.banner {
  &.success {
    @include banner($color-success);
  }
  &.error {
    @include banner($color-error);
  }
  &.info {
    @include banner($color-info);
  }
}

.banner::after {
  content: "";
  position: absolute;
  height: $overshoot;
  width: 100%;
  bottom: 100%;
  left: 0;
}

.banner:not(.visible) {
  display: none;
  transform: translateY(-100%);
}

.banner.visible {
  box-shadow: 0 2px 2px 2px rgba(0, 0, 0, 0.12);
  animation-name: banner-in;
  animation-direction: forwards;
  animation-duration: 0.6s;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
  animation-iteration-count: 1;
}

@keyframes banner-in {
  0% {
    transform: translateY(-100%);
  }

  50% {
    transform: translateY($overshoot);
  }

  100% {
    transform: translateY(0);
  }
}

.show-banner {
  appearance: none;
  background: #ededed;
  border: 0;
  padding: 1rem 2rem;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  margin: 0.25rem;
}

              
            
!

JS

              
                // Pssst, I've created a github package - https://github.com/brookesb91/dismissible

const showBanner = (selector) => {
  hideBanners();
  // Ensure animation plays even if the same alert type is triggered.
  requestAnimationFrame(() => {
    const banner = document.querySelector(selector);
    banner.classList.add("visible");
  });
};

const hideBanners = (e) => {
  document
    .querySelectorAll(".banner.visible")
    .forEach((b) => b.classList.remove("visible"));
};

              
            
!
999px

Console