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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="content">
  <div class="card">
    <h1 class="card__heading">Heading</h1>
    <p class="card__text">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.</p>
    <button class="card__button">Send Message</button>
  </div>
</div>
              
            
!

CSS

              
                // Text contrast based in Jonny Kates post
//https://medium.com/@jonnykates
//-------------------------------------------------------------------------

@function text-contrast($n) {
  $color-brightness: round((red($n) * 299) + (green($n) * 587) + (blue($n) * 114) / 1000);
  $light-color: round((red(#ffffff) * 299) + (green(#ffffff) * 587) + (blue(#ffffff) * 114) / 1000);
  @if abs($color-brightness) < ($light-color/2){
    @return #FAFAFA;
  }
  @else {
    @return #1A1A1A;
  }
}


// Here we generate the complimentary pallet of the color
//-------------------------------------------------------------------------
@function generate-pallete($color) {
  $complementary: if(saturation($color) == 0 and saturation($color) != saturation(invert($color)), invert($color), complement($color));
  $font-color-main: text-contrast($color);
  $font-color-complementary: text-contrast($complementary);

  @return (
    "base-color" : $color,
    "font-color-main": $font-color-main,
    "complementary-color": $complementary,
    "font-color-complementary": $font-color-complementary,
  );
}

// Here we generate a random color animation
//-------------------------------------------------------------------------
$random: random(360);
$base-color: hsl($random, 100, 60);

$pallete: generate-pallete($base-color);
$font-color: map-get($pallete, "font-color-main");
$complementary: map-get($pallete, "complementary-color");
$font-color-complementary: map-get($pallete, "font-color-complementary");

* {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', sans-serif;
}

.content{
  height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  animation: shift .6s forwards infinite ease-in-out;
}

.card {
  align-items: flex-start;
  background: map-get($pallete, "base-color");
  border-radius: 8px;
  box-shadow: 0px 2px 10px -2px mix(black, white, 20%);
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-between;
  max-width: 200px;
  min-height: 180px;
  padding: 15px;
  width: auto;
  &__heading{
    color: $font-color;
    line-height: 1.6;
  }
  &__text{
    color: $font-color;
    line-height: 1.4;
  }
  &__button{
    all: unset;
    align-self: flex-end;
    background: $complementary;
    border-radius: 4px;
    box-shadow: 0px 2px 6px 2px mix(black, $base-color, 20%);
    color: $font-color-complementary;
    cursor: pointer;
    line-height: 1.8;
    margin-top: 32px;
    padding: 5px 12px;
    vertical-align: center;
    transition: 
      background .6s ease-in,
      box-shadow .6s ease-in;
    &:hover{
      background: mix(black, $complementary, 15%);
      box-shadow: 0px 8px 8px -5px mix(black, $base-color, 30%);
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console