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

              
                # Tab focus with box-shadow

Attempting to improve upon the Bootstrap 4 method of using `box-shadow`s for a custom `outline`. Demos include an unfocused button, as well as a manually focused one.

## Transparent border
Adds a transparent `border` and clipping the background to the element's `padding`. This can work with nearly every element as `border`s can be recreated with `box-shadow: inset`.
 
<button class="button" type="button">Button</button> <button class="button focused" type="button">Button</button>

## Pseudo-element
Generates a pseudo-element with `::after` to keep the focus styles off the main element, allowing the `<button>` to have a normal `border`. Downside is this doesn't work on `<input>`s.

<button class="button2" type="button">Button</button> <button class="button2 focused">Button</button>


              
            
!

CSS

              
                .button {
  display: inline-block;
  padding: .5rem 1rem;
  font: inherit;
  color: #fff;
  border: .1875rem solid transparent;
  border-radius: .5rem;
  background-color: rgb(46,139,87); // `seagreen`
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); // makeshift border
  
  &:focus,
  &.focused {
    outline: 0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), 0 0 0 .1875rem rgba(46,139,87,.25);
  }
}

.button2 {
  position: relative;
  display: inline-block;
  padding: .5rem 1rem;
  font: inherit;
  color: #fff;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: .5rem;
  background-color: rgb(0,0,255);
  
  &::after {
    position: absolute;
    top: -.1875rem;
    right: -.1875rem;
    bottom: -.1875rem;
    left: -.1875rem;
    display: none;
    content: "";
    border-radius: .625rem;
    box-shadow: 0 0 0 .1875rem rgba(0,0,255,.25);
  }
  
  &:focus,
  &.focused {
    outline: 0;
    &::after {
      display: block;
    }
  }
}


//
// Demo page styles, ignore
//

body {
  padding: 2rem 2rem 4rem;
  margin: 0;
  font: 16px/1.5 -apple-system, sans-serif;
  color: #333;
  text-align: center;
  background-color: #f5f5f5;
}

h1, h2 {
  margin-bottom: .5rem;
}

p, div {
  margin-left: auto;
  margin-right: auto;
  max-width: 44rem;
}

              
            
!

JS

              
                          
              
            
!
999px

Console