css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="t-orange">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>

<div class="t-purple">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>

<div class="t-tomato">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>

<div class="t-navy">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>

<div class="t-teal">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>

<div class="t-gray">
  <div class="c-card">
    <h2 class="c-card__heading">A Heading</h2>

    <p>Macaroon jelly-o jelly-o caramels cupcake pastry sweet sweet roll. Croissant marshmallow toffee fruitcake oat cake. Cupcake chocolate bar toffee cake lollipop halvah toffee pudding.</p>
  </div>
</div>
            
          
!
            
              // We only want to generate fallback classes if they are needed.
// You can set the variable at the top of your stylesheet(s).
// This allows you to generate a stylesheet for modern browsers and one for older browsers.
// hint: checkout the compiled CSS with the variable set to false and then again set to true!
$no-variable-support: false !default;

$themes: (orange, purple, tomato, navy, teal, gray);

// Everything nested in this if block will generate all of the CSS variables and their classes.
// We only want to include this code if we're generating a stylesheet for modern browsers.
@if $no-variable-support == false {
  // GENERATE THEME VARIABLES
  // ------------------------
  :root {
    // Loop through the $themes sass-map to generate our color variables.
    // example: --theme-orange: orange;
    @each $themeColor in $themes {
      --theme-#{$themeColor}: #{$themeColor};
    }

    // This variable will be used to style all themed patterns.
    // This variable will be updated depending on the parent theme.
    // We have to set the variable here and give it a default value.
    --theme: var(--theme-gray);
  }

  // GENERATE THEME CLASSES
  // ----------------------
  @each $themeColor in $themes {
    // These are the classes that update the CSS --theme variable.
    // They should be applied to the parent element.
    .t-#{$themeColor} {
      --theme: var(--theme-#{$themeColor});
    }
  }
}

// GENERATE FALLBACK CLASSES
// -------------------------
// The add-theme() mixin is used in place of the css property that needs to be themed:
// .example {
//   @include sb-variable('color');
// }
@mixin add-theme($property) {
  @if $no-variable-support {
    @each $themeColor in $themes {
      .t-#{$themeColor} & {
        #{$property}: #{$themeColor};
      }
    }
  } @else {
    #{$property}: var(--theme);
  }
}

// PAGE STYLES
// -----------
.c-card {
  padding: 2rem;
  margin: 2rem;
  max-width: 700px;
  background: #eee;
  border-top-width: 3px;
  border-top-style: solid;
  @include add-theme('border-top-color');

  &__heading {
    margin-top: 0;
    @include add-theme('color');
  }
}
            
          
!
            
              // IE 11 and older do not support CSS variables, they also no longer support conditional comments for IE 10 & 11 so we need to update our base stylesheet with our fallback.

// This is assuming you have two stylesheets: 
// base.css - which uses css variables
// base-no-variables.css - which uses the fallback classes

// Ideally we would use Modernizr to detect Custom Property support but they don't have that feature yet. So for now we'll detect the browser*:
var isIE = /*@cc_on!@*/false || !!document.documentMode;

if (isIE) {
  // You can target your link element however you want but I chose to add an ID attribute.
  document.getElementById("baseCss").href = "base-no-variables.css";
}

// * Browser Detection:  https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser

// Note: This code is just an example of how you can implement the fallback solution in the CSS pane. We aren't providing fallback support for this pen.
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console