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="wrapper" id="app">
        <section class="[ chunk ] [ flow-vertical ]">
            <h1 class="heading heading--primary"><abbr title="Pixel">PX</abbr> to REM calculator</h1>
            <p class="summary">Use this nifty tool to convert your pixel sizes to REM units.</p>

            <form action="get" class="[ form ] [ flow-vertical ]">
                <div class="form__group">
                    <label for="root_size" class="is-hidden--text">Add your root size</label>
                    <label for="root_size" aria-hidden="true" role="presentation" class="form__label">My root size is</label>
                    <input type="number" min="1" max="99" step="1" name="root_size" id="root_size" :value="rootSize" class="form__field" @input="calculate" @blur="tidyInputVal" />
                    <label for="root_size" aria-hidden="true" role="presentation" class="form__label">px.</label>
                <div class="form__group">
                    <label for="required_size" class="is-hidden--text">Add your required pixel size</label>
                    <label for="required_size" aria-hidden="true" role="presentation" class="form__label">I want my text to be</label>
                    <input type="number" min="1" max="99" step="1" name="required_size" id="required_size" :value="pxSize" class="form__field" @input="calculate" @blur="tidyInputVal" />
                    <label for="required_size" aria-hidden="true" role="presentation" class="form__label">px.</label>
        <section class="[ breathe--double-top ] [ result ]">
            Your REM size is: <b class="result__value">{{ remSize }}rem</b>
            <figure class="result__snippet">
                <figcaption class="is-hidden--text">CSS snippet with your new REM size</figcaption>
                        .your-element {
                            font-size: {{ remSize }}rem;
        <footer class="credit">
            <p>Made with ❤️&nbsp; by <a href="https://hankchizljaw.io" rel="external">Hankchizljaw</a></p>

    This pen pulls in a default compilation
    of Stalfos' CSS

// Type
$base-font-family: 'Quicksand', sans-serif;

// Color
$charcoal: #333;
$magenta: #de6aec;

// Metric
$gutter: 20px;
$gutter--double: 40px;

html {
    font-size: 16px;

body {
    background: $magenta;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: $base-font-family;
    font-size: 1.250rem;
    line-height: 1.5;

abbr {
    text-decoration: none;
    border: none;
    outline: none;
    cursor: help;

a {
    color: $charcoal;
    &:focus {
        text-decoration: none;

.heading {
    font-weight: 400;
    &--primary {
        font-size: 2.250rem;
        line-height: 1.2;

.form {
    padding: $gutter 0 0 0;
    &__group {
        > * {
            display: inline;
    &__field {
        background: transparent;
        font-family: $base-font-family;
        padding: 2px 2px 0px 2px;
        border: none;
        font-size: 1.375rem;
        border: 1px solid transparent;
        border-bottom-color: $charcoal;
        position: relative;
        top: 1px;
        transition: all 200ms linear;
        &:focus {
            background: white;
            border-color: $charcoal;
            outline: none;
			border-radius: 3px;
    &__label {
        font-weight: 700;
        font-size: 1.375rem;

.result {
    border-top: 1px dashed $charcoal;
    padding: $gutter--double 0 0 0;
    font-size: 1.3rem;
    &__value {
        display: block;
        font-size: 2.188rem;
    &__snippet {
        pre {
            display: inline-block;
            padding: 16px $gutter $gutter $gutter;
            margin: $gutter 0 0 0;
            background: $charcoal;
            border-radius: 3px;
            white-space: normal;
        code {
            tab-size: 4;
            color: white;
            font-size: 1.2rem;
            line-height: 1;

.credit {
    padding: $gutter--double 0 $gutter 0;
    font-size: 1rem;
    font-weight: 700;
    color: $charcoal;
              const app = new Vue({
    el: '#app',
    data: {
        defaultRootSize: 16, // Used if the user leaves a field blank
        rootSize: 16,
        pxSize: 16,
        remSize: 1
    methods: {
        calculate(evt) {
            let self = this;
            // Attempt to parse the size from the evt input
            let parsedSize = (evt.target.value.length ? parseInt(evt.target.value, 10) : self.defaultRootSize);
            // Find the target and set the appropriate data value
            switch(evt.target.getAttribute('name')) {
                case 'root_size':
                    self.rootSize = parsedSize;
                case 'required_size':
                    self.pxSize = parsedSize;
            // Calculate rem sizw
            self.remSize = (self.pxSize / self.rootSize).toFixed(2);
            // Set it to 1 if something went wrong
            if(isNaN(self.remSize)) {
                self.remSize = 1;
        // Set the default root size if things get a bit larey
        tidyInputVal(evt) {
            if(!evt.target.value.length) {
                evt.target.value = self.defaultRootSize;
🕑 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.