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="wrapper">
  <div id="cookies" class="cookie-banner" role="alert">
    <div class="inner">
      <button type="button" id="close" class="button button-secondary">Close</button>
      <h2 class="cookie-heading">Obligatory cookie banner</h2>
      <div class="cookies-text">
              <fieldset>
                <legend>Which of these cookies can we use?
                </legend>

              <label for="choc-chip">
                <input id="choc-chip" type="checkbox" />
                <div class="pretty-checkbox" aria-hidden="true"></div> Chocolate chip
              </label>
              <label for="oatmeal-raisin">
                <input id="oatmeal-raisin" type="checkbox"/>
                 <div class="pretty-checkbox"></div>
                Oatmeal & raisin
              </label>
              </fieldset> 
        <button type="button" id="accept" class="button button-primary">Accept all
        </button>
      </div>
    </div>
            </div>
    <header class="header">
      <a class="title" href="#">The Woofer Times</a>
      <nav aria-label="Main navigation">
        <ul class="menu">
          <li><a href="#">News</a></li>
          <li><a href="#">Politics</a></li>
          <li><a href="#">World</a></li>
<li><a href="#">Sport</a></li>
      <li><a href="#">Tech</a></li>
        </ul>
        </nav>
    </header>
    <main class="main">
      <article>
        <h1>You won't believe this clickbaity headline</h1>
        <div class="byline">N De Plume - 5th June 2021</div>
        <p>Doggo ipsum heckin angery woofer very taste wow smol borking doggo with a long snoot for pats you are doing me a frighten, ur givin me a spook. H*ck waggy wags much ruin diet doggorino fluffer, shooberino long water shoob smol. Porgo much ruin diet wrinkler doggorino, shoob very jealous pupper.</p>
        <figure class="image"><img alt="a lovely fluffy samoyed" src="https://codepen-assets.s3.eu-west-2.amazonaws.com/alex-russell-saw-Dj8cxyi9ink-unsplash-1.jpg" />
          <figcaption class="caption">"The most angery pupper I have ever seen" Photo: <a href="https://unsplash.com/@alexrussellsaw?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Alex Russell-Saw</a></figcaption>
        </figure>
        <p> Borkf adorable doggo boof h*ck maximum borkdrive, most angery pupper I have ever seen shibe big ol pupper, heckin angery woofer extremely cuuuuuute ruff. Woofer big ol I am bekom fat pupperino shooberino, long bois snoot. </p>
        <h2>And then something else happened</h2>
        <p>Blop smol pats doge you are doin me a concern, long water shoob wrinkler. Much ruin diet clouds fluffer long water shoob, pupper. Ruff heckin good boys and girls wow very biscit h*ck mlem, blop borking doggo. Such treat dat tungg tho doggorino boof puggorino, very jealous pupper much ruin diet.</p>

        <p>Yapper long woofer what a nice floof I am bekom fat shoob ur givin me a spook such treat, borking doggo boof fluffer pupper. Heckin angery woofer borkdrive fluffer porgo doggo, smol borking doggo with a long snoot for pats long doggo. Very taste wow I am bekom fat long water shoob snoot long water shoob borkdrive heckin angery woofer, pats pupperino stop it fren long woofer heck. I am bekom fat smol boof very taste wow boofers shoob, noodle horse fluffer ruff. Clouds pupperino very good spot blop such treat most angery pupper I have ever seen, maximum borkdrive floofs bork.</p>
      </article>
    </main>
    <footer class="footer">
      <p>© some media conglomerate 2021</p>
      <div class="columns">
        <ul class="footer-links" role="menu">
          <li><a href="#">About us</a></li>
          <li><a href="#">Careers</a></li>
          <li><a href="#">Contact us</a></li>
          <li><a href="#">Help</a></li>
        </ul>
        <ul class="social" role="menu" aria-label="Social links">
          <li class="social-link"><a href="https://twitter.com/type__error">Twitter</a></li>
          <li class="social-link"><a href="https://twitter.com/type__error">Facebook</a></o>
          <li class="social-link"><a href="https://twitter.com/type__error">Instagram</a></li>
          <li class="social-link"><a href="https://twitter.com/type__error">Tinder</a></li>
        </ul>
      </div>
    </footer>
  </div>
              
            
!

CSS

              
                a {
  color: white;
  font-weight: bold;
  text-decoration: none;
}
body {
  font-size: 16px;
  margin: 0;
  height: 100vh;
  font-family: "Helvetica Neue", Arial, sans-serif;
}


.visually-hidden {
  display: block;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px 1px 1px 1px);
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(1px);
  white-space: nowrap;
  position: absolute;
}

.wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.header {
  background-color: #420a55;
  padding: 1rem;
  color: white;

  .title {
    font-size: 2rem;
    font-weight: 700;
    display: inline-block;
    margin: 1.5rem 0;
  }
  .menu {
    display: flex;
    padding: 0;
    margin: 0;
    justify-content: space-evenly;
    list-style-type: none;
    &-item {
      font-weight: bold;
    }
  }
}

.main {
  flex: 1;
  padding: 1.5rem 3rem;
  a {
    color: initial;
  }
  h1 {
    font-size: 2rem;
  }

  .byline {
    font-style: italic;
  }
  .image {
    text-align: center;
    img {
      width: 60%;
    }
    figcaption {
      font-style: italic;
    }
  }
}

.footer {
  text-align: center;
  padding: 1rem;
  background: #420a55;
  color: white;

  .columns {
    justify-content: center;
    display: flex;
    text-align: left;
    ul {
      list-style-type: none;
    }
    .social {
      margin-left: 1rem;
    }
  }
}

.cookie-banner {
  position: sticky;
  top: 0;
  background-color: #f0f0f0;
  width: 100%;
  
  .cookie-heading {
    display: inline-block;
    margin: 1rem 0;
    font-size: 1.8rem;
    font-weight: 700;
  }
  fieldset {
    border: 0;
  }
  .inner {
    position: relative;
    padding: 1rem;
  }
  #close {
    position: absolute;
    right: 1rem;
    font-size: 1rem;
    cursor: pointer;
  }

  .button {
    cursor: pointer;
    border: 0;
    box-shadow: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    margin: auto 0;
    justify-content: center;
    align-items: center;
    padding: 0.8rem 1rem;
    &-primary {
      color: white;
      background-color: #420a55;
      &:hover {
        background: #8d6c99;
      }
    }
    &-secondary {
        background: white;
      border: 1px solid #aaaaaa; 
      &:hover {
        background: #aaaaaa; 
      }
    }
  }
  label {
    display: block;
  }
  
  .pretty-checkbox {
    display: inline;
    &:before {
      display: inline-block;
      color: purple;
      content: " ";
            margin-bottom: -2px;

background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23420a55' viewBox='0 0 46 46'%3e%3cpath d='M35.822 0H10.178C4.557 0 0 4.557 0 10.178v25.646C0 41.443 4.557 46 10.178 46h25.645C41.443 46 46 41.443 46 35.822V10.178C46 4.557 41.443 0 35.822 0zM40 35.822A4.182 4.182 0 0135.822 40H10.178A4.182 4.182 0 016 35.822V10.178A4.182 4.182 0 0110.178 6h25.645A4.182 4.182 0 0140 10.178v25.644z'/%3e%3c/svg%3e");
      background-repeat: no-repeat;
      width: 16px;
      height: 16px;
    }
  }
  
  input {
    @extend .visually-hidden;
    &:checked + .pretty-checkbox:before {
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23420a55' viewBox='0 0 46 46'%3e%3cpath d='M35.822 0H10.178C4.557 0 0 4.557 0 10.178v25.646C0 41.443 4.557 46 10.178 46h25.645C41.443 46 46 41.443 46 35.822V10.178C46 4.557 41.443 0 35.822 0zM40 35.822A4.182 4.182 0 0135.822 40H10.178A4.182 4.182 0 016 35.822V10.178A4.182 4.182 0 0110.178 6h25.645A4.182 4.182 0 0140 10.178v25.644z'/%3e%3cpath d='M21.925 33.298a3.253 3.253 0 01-4.596 0l-7.122-7.122a3.25 3.25 0 114.597-4.596l4.243 4.242c.321.32.84.32 1.161 0l11.489-11.489c1.27-1.27 3.326-1.27 4.597 0s1.271 3.327 0 4.597L21.925 33.298z'/%3e%3c/svg%3e");
    }
  }

  .cookies-text {
    width: 80%;
    display: flex;
    justify-content: space-between;
  }

  &.hidden {
    display: none;
  }
}

              
            
!

JS

              
                  let selected = [];

function selectCookie(cookie) {
  if (selected.includes(cookie)) {
    selected = selected.filter((c) => c !== cookie);
    document.getElementById(cookie).checked=false;
    return;
  }
  selected.push(cookie);
  document.getElementById(cookie).checked=true;
}

document.getElementById("choc-chip").onclick = () => selectCookie("choc-chip");
document.getElementById("oatmeal-raisin").onclick = () =>
  selectCookie("oatmeal-raisin");

document.getElementById("close").onclick = closeCookies;

document.getElementById("accept").onclick = closeCookies;

function closeCookies() {
  document.getElementById("cookies").classList.add("hidden");
}

              
            
!
999px

Console