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='title__container'>
  <h1 class='page__title'>Alerts Component</h1>
</div>

<div class='alert__container'>
  <div class='alert alert__primary spacer' role='alert'>
    <i class="fas fa-exclamation-circle alert__icon"></i>
    <p class='alert__text'>This is a primary alert</p>
    <button type="button" class="alert__close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true"><i class="fas fa-times-circle alert__close"></i></span>
    </button>
  </div>
  <div class='alert alert__secondary spacer' role='alert'>
    <i class="fas fa-exclamation-circle alert__icon"></i>
    <p class='alert__text'>This is a secondary alert</p>
    <button type="button" class="alert__close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true"><i class="fas fa-times-circle alert__close"></i></span>
    </button>
  </div>
  <div class='alert alert__warning spacer' role='alert'>
    <i class="fas fa-exclamation-triangle alert__icon"></i>
    <p class='alert__text'>This is an warning alert</p>
    <button type="button" class="alert__close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true"><i class="fas fa-times-circle alert__close"></i></span>
    </button>
  </div>
  <div class='alert alert__error spacer' role='alert'>
    <i class="fas fa-minus-circle alert__icon"></i>
    <p class='alert__text'>This is an error alert</p>
    <button type="button" class="alert__close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true"><i class="fas fa-times-circle alert__close"></i></span>
    </button>
  </div>
  <div class='alert alert__success spacer' role='alert'>
    <i class="fas fa-check-circle alert__icon"></i>
    <p class='alert__text'>This is a success alert</p>
    <button type="button" class="alert__close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true"><i class="fas fa-times-circle alert__close"></i></span>
    </button>
  </div>
</div>
              
            
!

CSS

              
                //variables
$alertPrimary: #ccf2ff;
$alertSecondary: #E2E3E3;
$alertWarning: #ffff99;
$alertError: #ffb3b3;
$alertSuccess: #d6f5d6;

body {
  background-color: #f0f0f0;
  font-family: 'Roboto', sans-serif;
}

.page__title {
  text-align: center;
  text-transform: uppercase;
}

.alert__container {
  background-color: rgba(255,255,255, 0.75);
  margin: 0 auto;
  width: 50%;
  padding: 1rem;
  border-radius: .25rem;
  border: .125rem solid black;
  
  .spacer {
    margin-bottom: 1rem;
  }
  
  .alert {
    border-radius: .125rem;
    // border: 1px solid black;
    padding: .5rem;
    color: black;
    
    &__icon{
      margin: 0 1rem;
    }
    
    &__text {
      display: inline-block;
      font-size: 1.125rem;
    }
    
    &__close {
      float: right;
      padding: .75rem .75rem;
      color: black;
      background-color: transparent;
      border: 0;
      cursor: pointer;
      
      span {
        font-size: 1rem;
      }
    }
    
    &__primary {
      background-color: $alertPrimary;
    }
    
    &__secondary {
      background-color: $alertSecondary;
    }
    
    &__warning {
      background-color: $alertWarning;
    }
    
    &__error {
      background-color: $alertError;
    }
    
    &__success {
      background-color: $alertSuccess;
    }
  }
}

.closed {
  display: none;
}
              
            
!

JS

              
                $('.alert__close').click(function() {
  $(this).parent().addClass('closed');
});
              
            
!
999px

Console