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="text">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nunc velit, gravida sed justo luctus, tincidunt condimentum quam. Integer mattis fermentum auctor. Nunc magna risus, tempor at varius ac, vestibulum sit amet sem. Nunc nunc lacus, pharetra id vulputate id, imperdiet id arcu. Quisque ut convallis velit. Suspendisse ex nibh, auctor nec nulla id, feugiat vehicula lorem. Donec eget ullamcorper urna. Pellentesque magna arcu, tempus sed luctus vitae, vehicula ac urna. Nam ac sem sit amet sem ultricies lacinia. Nulla eget tellus dui. Nunc hendrerit vestibulum nisl vel ultrices. Donec lorem turpis, porttitor ac commodo non, sagittis eget ligula. Etiam hendrerit mollis est vel bibendum. Praesent efficitur interdum tincidunt.</p>

  <p>Nam non fringilla risus. Sed augue neque, egestas et porttitor condimentum, ullamcorper et nulla. Phasellus interdum sollicitudin neque at accumsan. Nulla faucibus libero nisl, non mattis dolor porttitor in. Morbi felis metus, efficitur id accumsan eu, sodales sit amet nulla. Vestibulum in lectus eu augue luctus pretium id vel nunc. Nam sit amet euismod purus. Praesent mattis libero est, a sagittis tortor sodales non. Praesent finibus nisi posuere magna elementum maximus.</p>

</div>

    <div class="switch-group">
        <label id="Label_fontDancing" for="fontDancing">Dancing Script</label>
        <div class="switch-container">
          <input class="switch switch--left" type="radio" name="font" id="fontDancing" value="dancing" checked="checked">
          <input class="switch switch--right" type="radio" name="font" id="fontDyslexic" value="dyslexic">
          <span class="status"></span>
        </div>
        <label id="Label_fontDyslexic" for="fontDyslexic">Open Dyslexic</label>       
    </div>
  <div class="switch-group">
        <label id="Label_lightTheme" for="lightTheme">Light theme</label>
        <div class="switch-container switch-container--theme">
          <input class="switch switch--left" type="radio" name="theme" id="lightTheme" value="light" checked="checked">
          <input class="switch switch--right" type="radio" name="theme" id="darkTheme" value="dark">
          <span class="status"></span>
        </div>
        <label id="Label_darkTheme" for="darkTheme">Dark theme</label>     
    </div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Dancing+Script:400,700');

@font-face {
  font-family: 'opendyslexic';
	src: url('https://dyslexicfonts.com/fonts/OpenDyslexic-Regular.otf');
	font-style: normal;
	font-weight: normal;
} 

@font-face {
	font-family: 'opendyslexic';
	src: url('https://dyslexicfonts.com/fonts/OpenDyslexic-Bold.ttf');
	font-weight: bold;
	font-style: normal;
} 

:root {	
	--font-family: 'Dancing Script';
	--bg-color: #fff;
	--color: #222;
  
  /* Radio button style */
  --width: 5rem;
  --height: 5rem;
  --border: 10px;
  --circle-diameter: 3rem;  
}

* {
	font-size: 16px;
	font-family: var(--font-family);
	color: var(--color);
	background-color: var(--bg-color);
  transition: all .5s ease-in-out;
}

.text {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 80vw;
  height: auto;
  min-height: 200px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0px 1px 3px 2px var(--color);
}

#Label_fontDancing {
	font-family: 'Dancing Script', Arial, sans-serif !important;
}

#Label_fontDyslexic {
	font-family: 'opendyslexic', Arial, sans-serif !important;
}

label {
  width: 15ch;
  text-align: center;
	cursor: pointer;
}

.switch-group {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: min-content;
  margin: 20px auto;
}

/* Radio button styles */
.switch-container {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: min-content;
  margin: 20px auto;
  border-radius: 25% / 50%;
  box-shadow: 0px 2px 3px 1px #333;
}
.switch-container .switch {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: var(--width);
  height: var(--height);
  margin: 0;
  cursor: pointer;
}
.switch-container .switch:before {
  content: '';
  width: 100%;
  height: 100%;
  position: relative;
  top: 0;
  left: 0;
  border: var(--border) solid #009294;
  box-sizing: border-box;
  background: linear-gradient(aquamarine, darkturquoise);
}
.switch-container .switch--left:before {
  border-top-left-radius: 50%;
  border-bottom-left-radius: 50%;
  border-right: 0;
}
.switch-container .switch--right:before {
  border-top-right-radius: 50%;
  border-bottom-right-radius: 50%;
  border-left: 0;
}
.switch-container span {
  left: calc(0px + var(--border));
  width: calc(var(--circle-diameter) + (var(--border)) );
  height: calc(var(--circle-diameter) + (var(--border)) );  
  border-radius: 50%;
  box-sizing: content-box;
  background-color: darkturquoise;
  z-index: 2;
  transition: all .3s ease-in-out;
}
.switch-container .switch--left:checked ~ span {
  display: block;
  position: absolute;
  left: calc(0px + var(--border));
  box-shadow: inset 0 0 10px 5px #00b0b3, 1px 0px 5px 1px #666;
}
.switch-container .switch--right:checked ~ span {
  display: block;
  position: absolute;
  left: calc( 100% - var(--circle-diameter) - (var(--border)*2) );  
  box-shadow: inset 0 0 10px 5px #00b0b3, -1px 0px 5px 1px #666;  
}




.switch-container--theme .switch--left:before {
  background: linear-gradient(to right, #fff, gray);
  border-color: #eee;
}
.switch-container--theme .switch--right:before {
  background: linear-gradient(to right, gray, #000);
  border-color: #111;
}
.switch-container--theme span {
  background-color: silver;
}
.switch-container--theme .switch--left:checked ~ span {
  box-shadow: inset 0 0 10px 5px #8a8a8a, 1px 0px 5px 1px #666;
}
.switch-container--theme .switch--right:checked ~ span {
  box-shadow: inset 0 0 10px 5px #8a8a8a, -2px 0px 2px 0px #ddd;  
}


              
            
!

JS

              
                


document.addEventListener("DOMContentLoaded", function(event) {

    
    /*
    let f = Cookies.get("font");

    if ( (typeof f === "undefined") || (f === 'dancing') ) {
        root.style.setProperty('--font-family', 'Dancing Script');
        document.getElementById("fontDancing").checked = true;
        document.getElementById("fontDyslexic").checked = false;
    } else {
        root.style.setProperty('--font-family', 'opendyslexic' );
        document.getElementById("fontDyslexic").checked = true;
        document.getElementById("fontDancing").checked = false;
    }*/
  
    const root = document.documentElement;
    const fonts = document.querySelectorAll('input[name="font"]');

    fonts.forEach((font) => {
        font.addEventListener('click', changeFont)  
    })

    function changeFont(ev) {
      console.dir(ev.target.value);
        switch (ev.target.value) { 
                case 'dancing':
                    root.style.setProperty('--font-family', 'Dancing Script');
                    //Cookies.set("font", "dancing", { expires: 30 });
                    break;
                case 'dyslexic':
                    root.style.setProperty('--font-family', 'opendyslexic');
                    //Cookies.set("font", "dyslexic", { expires: 30 });
                    break;            
        }
    }

    //let t = Cookies.get("theme");

    
    
    /*if ((typeof t === "undefined") || (t === 'light')) {
        root.style.setProperty('--bg-color', '#fff');
        root.style.setProperty('--color', '#222');
        document.getElementById("lightTheme").checked = true;
        document.getElementById("darkTheme").checked = false;
    } else {
        root.style.setProperty('--bg-color', '#222');
        root.style.setProperty('--color', '#fff');
        document.getElementById("darkTheme").checked = true;
        document.getElementById("lightTheme").checked = false;
    }*/
  
    const themes = document.querySelectorAll('input[name="theme"]');
    
    themes.forEach((theme) => {
        theme.addEventListener('click', changeTheme)
    })

    function changeTheme(ev) {
        switch (ev.target.value) {
            case 'light':
                root.style.setProperty('--bg-color', '#fff');
                root.style.setProperty('--color', '#222');
                //Cookies.set("theme", "light", { expires: 30 });
                break;
            case 'dark':
                root.style.setProperty('--bg-color', '#222');
                root.style.setProperty('--color', '#fff');
                //Cookies.set("theme", "dark", { expires: 30 });
                break;
        }
    }

});



              
            
!
999px

Console