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

              
                <div class="contain">
  <div class="range">
    <label for="range">Drag to change font-size:</label>
    <input type="range" name="" id="range" min="10" max="40" />
    <span class="current"></span>
  </div>
  <div class="item">
    <p>The quote icon is positioned absolutely and <em>left</em> property is set with <em>em</em></p>
    <blockquote class="quote">
      <p><span>Building dynamic web components using modular design concepts is awesome. <em>- Ahmad Shadeed</em></span></p>
    </blockquote>

    <blockquote class="quote quote--dynamic">
      <p><span>Building dynamic web components using modular design concepts is awesome. <em>- Ahmad Shadeed</em></span></p>
    </blockquote>

    <p>Bad example: the quote icon is overlapping the text, because <em>left</em> property is set with <em>px</em></p>

    <blockquote class="quote quote--px">
      <p><span>Building dynamic web components using modular design concepts is awesome. <em>- Ahmad Shadeed</em></span></p>
    </blockquote>
  </div>
</div>
              
            
!

CSS

              
                $browser-context: 16; // Default
$color-brand: #4a90e2;

body {
	font-family: 'Arial';
}

.contain {
	max-width: 1000px;
	margin-left: auto;
	margin-right: auto;
	padding-left: 1em;
	padding-right: 1em;
}

.range {
  padding-top: 2em;
  margin-bottom: 2em;
  
  label {
    display: block;
    margin-bottom: 10px;
  }
}

@function em($pixels, $context: $browser-context) {
  @return #{$pixels/$context}em;
}

/* Sass function credit:
https://css-tricks.com/snippets/sass/px-to-em-functions/ */

/*********************************/
/*** Demo Code ***/
/*********************************/

.quote {
	position: relative;
	margin: 0;
	background: $color-brand;
	padding: 1.5em 2em;
	padding-left: 4.5em;
	border-radius: em(5);
	margin-bottom: 16px;
  line-height: 1.5;

	p {
		margin: 0;
		font-size: 2em;
	}

	em {
		all: initial;
		color: #fff;
		font-family: inherit;
	}

	span {
		color: #fff;
		box-shadow: inset 0 em(-4) 0 0 transparentize(#fff, 0.6);
	}

	&:before {
		content: "";
		position: absolute;
		top: em(34);
		left: em(30);
		background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/182774/quotes.svg') no-repeat;
		background-size: 100%;
		height: em(30);
		width: em(30);
	}
}

.quote--px {
	padding: 24px 32px;
	padding-left: em(72);
	border-radius: 5px;

	p {
		font-size: 32px;
	}

	span {
		color: #fff;
		box-shadow: inset 0 -8px 0 0 transparentize(#fff, 0.6);
	}

	&:before {
		content: "";
		top: 30px;
		left: 30px;
    width: 30px;
    height: 30px;
	}
}

.quote--dynamic {
	font-size: 1.35em;
}
              
            
!

JS

              
                var slider = document.querySelector('#range');
    item = document.querySelector('.item'),
    current = document.querySelector('.current'),
    style = window.getComputedStyle(item, null).getPropertyValue('font-size'),
    fontSize = parseFloat(style);

current.innerHTML = fontSize + "px";

range.addEventListener('input', function() {
  var newValue = this.value + "px";
  item.style.fontSize = newValue;
  current.innerHTML = newValue;
});
              
            
!
999px

Console