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

              
                <body>
  <header>
    <nav>
      <button class="nav" onclick="changeColor('https://www.imarketinx.de/codepen/theming-with-css-variables/spring.css')">Spring</button> &bull; <button class="nav" onclick="changeColor('https://www.imarketinx.de/codepen/theming-with-css-variables/summer.css')">Summer</button> &bull; <button class="nav" onclick="changeColor('https://www.imarketinx.de/codepen/theming-with-css-variables/autumn.css')">Autumn</button> &bull; <button class="nav" onclick="changeColor('https://www.imarketinx.de/codepen/theming-with-css-variables/winter.css')">Winter</button>
    </nav>
    <div class="site-header">
      <h1>Website in the Four Seasons</h1>
    </div>
  </header>
  <main>
    <section>
      <header>
        <h2>Change Website Colour Scheme with CSS Variables as Needed</h2>
        <h3>Theming with CSS Variables</h3>
        <h4>Read more about Theming on my <a href="https://www.imarketinx.de/artikel/theming-with-css-variables.html">Website</a></h4>
      </header>
      <article>
        <p class="lead"> This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph. This is the Lead Paragraph.</p>
        <p> This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
        <h4>Article Header</h4>
        <p> This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
        <div class="box-hilite">
          <h5>Highlight</h5>
          <p> This is a default Paragraph. This is a default Paragraph with a <a href="https:www.imarketinx.de" target="_blank">Link</a> to my Homepage. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
          <p> This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
          <p class="center"><button>Button</button></p>
        </div>
        <p> This is a default Paragraph. This is a default Paragraph with a <a href="https:www.imarketinx.de" target="_blank">Link</a> to my Homepage. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
      </article>
    </section>
  </main>
  <aside>
    <article>
      <h5>Aside Header</h5>
      <p> This is a default Paragraph. This is a default Paragraph with a <a href="https:www.imarketinx.de" target="_blank">Link</a> to my Homepage. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
      <p> This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph. This is a default Paragraph.</p>
      <p class="center"><button>Button</button></p>
    </article>
  </aside>
  <footer>
    <h6>Footer</h6>
    <ul>
      <li>item 1</li>
      <li>item 2</li>
      <li>item 3</li>
      <li>item 4</li>
    </ul>
  </footer>
</body>
              
            
!

CSS

              
                /*=========================================================
 * General Settings with CSS Custom Properties (Variables)
==========================================================*/
:root {
  --max-width: 1280px;
  --spacing: 1;
  --font-family: Ubuntu, Helvetica, Tahoma, Arial, "sans-serif";
  --font-size: 1;
  --line-height: 1;
  --text-shadow: 1px 1px #bfbfbf;
  --border: 1px solid grey;
  --border-radius: .25rem;
  --box-shadow: 5px 5px 5px 0px rgba(153,153,153,1);
  --transition: all .5s ease;
}
/* Increase font size on screens 600px and larger */
@media (min-width: 600px) {
  :root {
    --font-size: 1.25;
    --spacing: 1.25;
  }
}

/*================================================
 * Theming with CSS Custom Properties (Variables)
=================================================*/
/* Color Themes */

/* Green Theme - Spring */
/*
:root {
  --colored-white: #F7FFF2;
  --pale-color: #E0FFCC;
  --lightest-color: #BCE6A1;
  --lighter-color: #9BCC7A;
  --light-color: #7BBF4D;
  --default-color: #69B336;
  --dark-color: #51991F;
  --darker-color: #30660A;
  --darkest-color: #1C4003;
  --strong-color: #102600;
  --color-accent-1: #FFA500;
  --color-accent-2: #E6E600;
}
*/

/* Blue Theme - Summer */
/*
:root {
  --colored-white: #F2F4FF;
  --pale-color: #CCD5FF;
  --lightest-color: #99ABFF;
  --lighter-color: #6681FF;
  --light-color: #3357FF;
  --default-color: #002BFF;
  --dark-color: #0024CC;
  --darker-color: #001B99;
  --darkest-color: #001266;
  --strong-color: #000933;
  --color-accent-1: #FFFF40;
  --color-accent-2: #E6E61F;
}
*/

/* Brown Theme - Autum  */
/*
:root {
  --colored-white: #FFFAF2;
  --pale-color: #FFEACC;
  --lightest-color: #FFD499;
  --lighter-color: #FFBF66;
  --light-color: #FFAA33;
  --default-color: #FF9500;
  --dark-color: #CC7700;
  --darker-color: #995900;
  --darkest-color: #663B00;
  --strong-color: #331D00;
  --color-accent-1: #A52A2A;
  --color-accent-2: #A50000;
}
*/

/* Red Theme - Winter  */
/*
:root {
  --colored-white: #FFF2F3;
  --pale-color: #FFBFC4;
  --lightest-color: #F29198;
  --lighter-color: #E6505B;
  --light-color: #D92B37;
  --default-color: #E6222E;
  --dark-color: #CC1420;
  --darker-color: #B30914;
  --darkest-color: #80020B;
  --strong-color: #400005;
  --color-accent-1: #008000;
  --color-accent-2: #004000;
}
*/

/*=========================
 * Custom Styles
==========================*/
* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  padding: .5rem 0;
  max-width: var(--max-width);
  font-family: var(--font-family);
  font-size: calc(var(--font-size) * 1rem);
  background-color: var(--colored-white);
  color: var(--strong-color);
  word-break: break-word;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
}

nav {
  padding: calc(var(--spacing) * .5rem);
  background-color: var(--default-color);
  color: var(--pale-color);
  border-bottom: 3px solid var(--color-accent-2);
}

.site-header {
  height: 200px;
  padding: calc(var(--spacing) * .75rem);
  text-align: center;
  background-color: var(--lightest-color);
}
.site-header h1 {
  text-shadow: var(--text-shadow);
  color: var(--color-accent-1);
}

main {
  margin: .75em 0;
  padding: calc(var(--spacing) * .5rem);
}

aside {
  margin: .75em 0;
  padding: calc(var(--spacing) * .5rem);
  background-color: var(--light-color);
  color: var(--colored-white);
}
aside h5 {
  text-shadow: var(--text-shadow);
  color: var(--color-accent-2);
}

.box-hilite {
  margin: calc(var(--spacing) * 1rem);
  padding: calc(var(--spacing) * .75rem);
  background-color: var(--pale-color);
  border: 1px solid var(--color-accent-1);
  border-radius: var(--border-radius);
}

footer {
  padding: calc(var(--spacing) * .5rem);
  background-color: var(--darkest-color);
}
footer,
footer h6 {
  color: var(--lightest-color);
}

/* Typography */
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
  padding: calc(var(--spacing) * .5rem);
}
h1, h4 {
  font-weight: 300;
}
h2, h3, h5, h6 {
  font-weight: 700;
}
h1 {
  font-size: calc(var(--font-size) * 3rem);
  line-height: calc(var(--line-height) * 1.1);
  color: var(--darkest-color);
}
h2 {
  font-size: calc(var(--font-size) * 2.5rem);
  line-height: calc(var(--line-height) * 1.25);
  color: var(--darker-color);
}
h3, h4, h5, h6 {
  line-height: calc(var(--line-height) * 1.5);
  color: var(--dark-color);
}
h3 {
  font-size: calc(var(--font-size) * 2rem);
}
h4 {
  font-size: calc(var(--font-size) * 1.75rem);
}
h5 {
  font-size: calc(var(--font-size) * 1.5rem);
}
h6 {
  font-size: calc(var(--font-size) * 1.25rem);
}

p {
  line-height: calc(var(--line-height) * 1.5);
}

.lead {
  font-size: calc(var(--font-size) * 1.15rem);
  font-weight: 300;
  color: var(--darker-color);
}

.center {
  text-align: center;
}

/* Style for Links */
a {
  color:var(--darker-color);
}
a:visited {
  color:var(--lighter-color);
}
a:hover,
a:active,
a:focus {
  color:var(--light-color);
}

aside a {
  color: var(--strong-color);
}
aside a:hover,
aside a:active,
aside a:focus {
  color:var(--colored-white);
}

button {
  padding: calc(var(--spacing) * .25rem);
  background: var(--darker-color);
  font-size: calc(var(--font-size) * 1.125rem);
  text-shadow: var(--text-shadow);
  cursor: pointer;
  color: var(--pale-color);
  border: 0;
  border-radius: var(--border-radius);
  transition: opacity .5s;
}
button:hover {
  opacity: .7;
}

button.nav {
  padding: calc(var(--spacing) * .25rem);
  font-size: calc(var(--font-size) * 1.125rem);
  text-shadow: none;
  color: var(--pale-color);
  background-color: transparent;
  border-radius: 0;
}

button.nav:active,
button.nav:focus {
  color: var(--strong-color);
}
              
            
!

JS

              
                  function changeColor(styles) {
    document.getElementById('change-color').setAttribute('href', styles)
  }
              
            
!
999px

Console