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="introduction">
  <h1 class="title">Using locally scoped custom properties</h1>
  <p>By using locally scopped properties, we can easily style individual components. The title here has a class of <code>.title</code>, as do the <code>h2</code> for each of the following sections.</p>
  <p>Because I'm using locally scoped properties to style them, I don't even need to select them, I only have to select the parent and change the value of the property.</p>
  <p>There is no need to define them in the global scope, as they aren't global properties. For example, the <code>--button-scale</code> has no need to be defined globally, as it's only used within my buttons.</p>
  <p>Working like this can help keep things nice and organized, yet very easy to make changes without getting into specificity wars or the need to go wild with extra classes to make minor modifications.</p>
</div>

<div class="cta">
  <h2 class="title">Join our awesome newsletter!</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam consequuntur repellat vero pariatur ipsum ut.</p>
  <ul class="icon-list">
    <li>Weekly content</li>
    <li>Special deals</li>
    <li>Super awesome stuff</li>
  </ul>
  <button class="button">Join now</button>
</div>

<div class="plans">
  <h2 class="title">Our plans</h2>
  <div class="pricing pricing-basic">
    <h2 class="category">Basic</h2>
    <p class="price">$99</p>
    <ul class="icon-list">
      <li>ipsum dolor</li>
      <li>voluptas ipsum</li>
      <li>earum assumenda</li>
      <li>eius delectus</li>
    </ul>
    <button class="button">Purchase</button>
  </div>
  <div class="pricing pricing-dark">
    <h2 class="category">Intermediate</h2>
    <p class="price">$199</p>
    <ul class="icon-list">
      <li>ipsum dolor</li>
      <li>voluptas ipsum</li>
      <li>earum assumenda</li>
      <li>eius delectus</li>
    </ul>
    <button class="button">Purchase</button>
  </div>
  <div class="pricing pricing-accent">
    <h2 class="category">Pro</h2>
    <p class="price">$299</p>
    <ul class="icon-list">
      <li>ipsum dolor</li>
      <li>voluptas ipsum</li>
      <li>earum assumenda</li>
      <li>eius delectus</li>
    </ul>
    <button class="button">Purchase</button>
  </div>
  <div class="pricing pricing-rainbow">
    <h2 class="category">Rainbow</h2>
    <p class="price">$999</p>
    <ul class="icon-list">
      <li>ipsum dolor</li>
      <li>voluptas ipsum</li>
      <li>earum assumenda</li>
      <li>eius delectus</li>
    </ul>
    <button class="button">Purchase</button>
  </div>
</div>

<footer>
  <h2 class="title">the end</h2>
  <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto tempore minima facere et, totam nesciunt?</p>
</footer>
              
            
!

CSS

              
                /* Setup a few global properties that can
   be reused to help with consistency */

:root {
  --clr-white: #efefef;
  --clr-lightgray: #ddd;
  --clr-darkgray: #333;
  --clr-accent: #ee6352;
  
  --icon-plus: "\f067";
  --icon-check: "\f00c";
}

/* styling each component by defining the custom properties */

.introduction {
  --title-size: calc(2rem + 5vw);
  --title-color: var(--clr-accent);
  
  padding: 5em 15vw;
}

.cta {
  --title-color: white;
  --list-icon: var(--icon-check);
  --list-icon-color: white;
  --button-bg: white;
  --button-text: var(--clr-darkgray);
  --button-scale: 2;
  
  background: var(--clr-accent);
  padding: 2em 15vw;
  margin-bottom: 3em;
}

.plans {
  --title-weight: 300;
  text-align: center;
}

.pricing {
  --list-icon: var(--icon-plus);
  
  background: var(--background);
  color: var(--text);
  padding: 3em 2em;
}

.pricing-basic {
  --background: var(--clr-white);
  --list-icon-color: var(--button);
}

.pricing-dark {
  --background: var(--clr-darkgray);
  --text: var(--clr-white);
}

.pricing-accent {
  --background: var(--clr-accent);
  --text: white;
  --button-bg: var(--clr-darkgray);
  --list-icon-color: var(--clr-darkgray);
}

.pricing-rainbow {
  /* you can do pretty much anything you want */
  --background: linear-gradient(-45deg, red, orange, yellow, green, blue, indigo, violet);
  --text: white;
  --list-icon: "\f75b";
  --list-icon-color: purple;
  --button-bg: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
  --button-text: red;
}

footer {
  --title-color: var(--clr-accent);
  --title-weight: 300;
  
  color: var(--clr-lightgray);
  background: var(--clr-darkgray);
  padding: 3em 15vw;
  margin-top: 5em;
}

/* setting everything up */


.title {
  color: var(--title-color, var(--clr-darkgray));
  font-size: var(--title-size, 2.5rem);
  font-weight: var(--title-weight, 700);
  
  margin: 0 0 .15em;
  grid-column: 1 / -1;
  line-height: 1;
}

.button {
  background: var(--button-bg, var(--clr-accent));
  color: var(--button-text, white);
  font-size: calc(var(--button-scale) * 1rem);
  
  padding: .5em 1.25em;
  border: 0;
  border-radius: 2em;  
  cursor: pointer;
  transition: transform 175ms;
}

.button:hover {
  transform: scale(1.1);
}

.icon-list {
  text-align: left;
  margin: 0 0 2em;
  padding: 0;
  list-style: none;
}

.icon-list li:before {  
  content: var(--list-icon);
  color: var(--list-icon-color);
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: .65em;
  float: left;
  margin: .5em 1em 0 0;
}

.category {
  margin: 0 0 .5em;
  text-transform: uppercase;
  font-weight: 300;
  font-size: .85rem;
  color: var(--clr-text);
  letter-spacing: 3px;
  line-height: .8;
}

.price {
  font-size: 4rem;
  margin: .25em 0;
}



/* generic styling that's not important
   for the demo */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: basic-sans, sans-serif;
  min-height: 100vh;
  font-size: 1.125em;
  line-height: 1.6;
  color: var(--clr-darkgray);
  background: var(--clr-lightgray);
}

.plans {
  background: white;
  width: 80vw; 
  margin: 0 auto;
  padding: calc(.5em + 3vw);
  box-shadow: 0 0 3em rgba(0,0,0,.15);
  display: grid;
  grid-gap: 1em;
  grid: auto / repeat(auto-fit, minmax(250px, 1fr));
}

code {
  background: rgba(238, 99, 82, .2);
}
              
            
!

JS

              
                
              
            
!
999px

Console