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

              
                <div class="container">
  <section class="section content">
    <h1 class="title">Simple Notifications</h1>
      <h2>Why?</h2>
      <p>We needed a light and simple notifications system with two kinds of possible behavior. Some notifications should <strong>close themselves</strong> without any action from the user. Some <strong>require clicking</strong> on the close button. All closed notifications should be removed from the DOM. The notifications may be on the page when it loads or may be added at any other moment.</p>
      <p>We don't use any JavaScript library but this demo uses <a href="https://bulma.io/">BULMA css framework.</a>You can disable BULMA styles in the panel at the bottom of the page.</p>
    <p class="notification is-danger" role="alert">Errors happen. And it happened again.<button class="delete" type="button">Close</button></p>
    <p data-close="self" class="notification is-info" role="alert">You've just found what you were looking for!</p>
    <p class="notification is-success" role="alert">You rock! Don't forget it! <button class="delete" type="button" >Close</button></p>
    <p data-close="self" class="notification is-warning" role="alert">Weather warnings for strong winds and rain!</p>
  </section>
</div>
<section class="add-new">
  <label>
    <input id="bulma-state" name="bulma" type="checkbox" checked>
    Bulma CSS Enabled
  </label>
  <div class="level is-mobile">
    <fieldset class="level-left level-item">
      <legend class="heading">Behavior</legend>
      <label>    
        <input name="self-closing" type="radio" value="yes" checked>
        Self closing
      </label>
      <label>
        <input name="self-closing" type="radio" value="no">
        With close button
      </label>
    </fieldset>
    <fieldset class="level-item">
      <legend class="heading">Type</legend>
      <label>
        <input name="notif-type" type="radio" value="info" checked>
        Info
      </label>
      <label>
        <input name="notif-type" type="radio" value="success">
        Success
      </label>
      <label>
        <input name="notif-type" type="radio" value="error">
        Error
      </label>
    </fieldset>
    <div class="level-right">
      <button id="add-new" type="button" class="button heading is-primary">Add new</button>
    </div>
  </div>
</section>

              
            
!

CSS

              
                @keyframes scaleup {
  0% {
    transform: scale(1)
  }
  100% {
    transform: scale(3);
    opacity: 0
  }
}

@keyframes scaledown {
  0% {
    transform: scale(1)
  }
  100% {
    transform: scale(0);
    opacity: 0
  }
}
              
            
!

JS

              
                var options = {
  animationOutSelf: 'scaleup 1s',
  animationOutClose: 'scaledown 0.5s',
  delayFunction: function(i){return i+1}
};
var notifications = new Notifications(".notification", options);
notifications.init();

              
            
!
999px

Console