Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <header class="page-header">
  <div class="logo-wrapper">
    <h1>RollingStone</h1>
  </div>
</header>
<main>
  <div class="features">
    <h2 class="visually-hidden">Features</h2>
    <article class="feature col2">
      <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
      <img src="https://assets.codepen.io/297176/austin-neill-725x870.jpg" alt="Just a singer in a rock'n'roll band" title="Foto van Austin Neill unsplash.com/@arstyy ">
    </article>
    <article class="feature col1">
      <h3>Lorem ipsum dolor sit amet</h3>
      <img src="https://picsum.photos/id/110/350/350" alt="">
    </article>
    <article class="feature col1">
      <h3>Lorem ipsum dolor sit amet, consectetur adipisicing</h3>
      <img src="https://picsum.photos/id/118/350/350" alt="">
    </article>
  </div>
  <div class="latest">
    <h2>The Latest</h2>
    <article>
      <header>
        <p>Lorem ipsum</p>
        <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
      </header>
    </article>
    <article>
      <header>
        <p>Lorem ipsum</p>
        <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
      </header>
    </article>
    <article>
      <header>
        <p>Lorem ipsum</p>
        <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
      </header>
    </article>
    <article>
      <header>
        <p>Lorem ipsum</p>
        <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
      </header>
    </article>
    <p><a href="">Meer nieuws</a></p>
  </div>
  <aside class="trending">
    <h2>Trending</h2>
    <ol>
      <li>
        <article>
          <h3>
            <div class="number">
              <span class="counter"></span>
            </div>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam commodi expedita natus obcaecati quae vero?</span>
          </h3>
        </article>
      </li>
      <li>
        <article>
          <h3>
            <div class="number">
              <span class="counter"></span>
            </div>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam commodi expedita natus obcaecati quae vero?</span>
          </h3>
        </article>
      </li>
      <li>
        <article>
          <h3>
            <div class="number">
              <span class="counter"></span>
            </div>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam commodi expedita natus obcaecati quae vero?</span>
          </h3>
        </article>
      </li>
      <li>
        <article>
          <h3>
            <div class="number">
              <span class="counter"></span>
            </div>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam commodi expedita natus obcaecati quae vero?</span>
          </h3>
        </article>
      </li>
      <li>
        <article>
          <h3>
            <div class="number">
              <span class="counter"></span>
            </div>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam commodi expedita natus obcaecati quae vero?</span>
          </h3>
        </article>
      </li>
    </ol>
  </aside>
</main>
<footer>
  <h2>That's all folks</h2>
</footer>
              
            
!

CSS

              
                @supports not (grid-template-columns: subgrid) {
  .page-header::before {
    position: relative;
    display: block;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    background: hsl(0 0% 100% / 0.5);
    content: "Je browser ondersteunt subgrid niet";
    font-size: 4rem;
    z-index: 1;
  }
}
/* ----------------
** Dit is de versie met de experimentele optie subgrid 
** Zie http://codepen.io/dool/pen/xxZqQBj 
** voor een uitwerking met grid-in-grid
** ------------------*/

/*
instellingen voor het raster
*/

main {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, auto);
}

.features {
  display: grid;
  grid-column: 1 / 5;
  grid-row: 1/ 3;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
}

.feature.col2 {
  grid-column: 1 / 5;
  grid-row: 1 / 2;
}

.feature:nth-of-type(2) {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
}

.feature:nth-of-type(3) {
  grid-column: 3 / 5;
  grid-row: 2 / 3;
}

.latest {
  grid-column: 1 / 5;
  grid-row: 3 / 4;
}

.trending {
  grid-column: 1 / 5;
  grid-row: 4 / 5;
}

@media screen and (min-width: 768px) {
  main {
    grid-template-columns: repeat(3, 1fr) 26%;
  }
  .feature.col2 {
    grid-column: 1 / 4;
    grid-row: 1 / 3;
  }
  .feature:nth-of-type(2) {
    grid-column: 4 /5;
    grid-row: 1 / 2;
  }
  .feature:nth-of-type(3) {
    grid-column: 4 / 5;
    grid-row: 2 / 3;
  }
}

@media screen and (min-width: 960px) {
  main {
    grid-template-columns: min(15%, 175px) 1fr 1fr 18.75rem;
  }
  .feature.col2 {
    grid-column: 2 / 4;
    grid-row: 1 / 2;
  }
  .feature:nth-of-type(2) {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
  }
  .feature:nth-of-type(3) {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
  }
  .latest {
    grid-column: 1 / 2;
    grid-row: 1 / 5;
  }
  .trending {
    grid-column: 4 / 5;
    grid-row: 1 / 5;
  }
}

@media screen and (min-width: 1100px) {
  main {
    grid-template-columns: min(15%, 175px) 1fr 15% 18.75rem;
  }
  .feature.col2 {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
  }
  .feature:nth-of-type(2) {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
  }
  .feature:nth-of-type(3) {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
  }
  .latest {
    grid-column: 1 / 2;
    grid-row: 1 / 5;
  }
  .trending {
    grid-column: 4 / 5;
    grid-row: 1 / 5;
  }
}

/*
reset en basisinstellingen
*/
*,
*::after,
*::before {
  box-sizing: border-box;
}

img {
  display: block;
  height: 100%;
  width: 100%;
}

.visually-hidden {
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  transition: all ease-out 0.1s;
}

.visually-hidden:focus {
  all: initial;
}

body {
  counter-reset: trending-counter;
  font-family: Georgia, Times, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.5;
}

body,
h1,
h2,
h3,
p {
  margin: 0;
}

li,
ol,
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h2,
h3 {
  font-family: neue-haas-unica, sans-serif;
}

/*
instellingen voor de paginaheader
 */

.page-header {
  background: crimson;
  height: 100px;
  width: 100%;
  transition: height 0.1s ease-in-out;
}

.logo-wrapper {
  background: white;
  box-shadow: 0 0.25rem 0.25rem 0 hsla(0 0% 0% / 0.2);
  position: fixed;
  text-align: center;
  width: 100%;
  z-index: 10;
}

h1 {
  background: linear-gradient(
    to right,
    #f06ca9,
    #f0608c,
    #ef3f50,
    #ed1e24,
    #f15d22,
    #f58120,
    #f78e1e,
    #f5a31f,
    #f5bd1e,
    #f5d01c,
    #f5de1a,
    #f5e719,
    #f5eb17,
    #e2de25,
    #b3c436,
    #6aa341 50%,
    #078e45,
    #23bdbd,
    #462e8d,
    #8b278a
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  font-family: "Zilla Slab", serif;
  font-size: 2.25rem;
  transition: font-size 0.1s ease-in-out;
}

@media screen and (min-width: 960px) {
  .page-header {
    height: 120px;
  }
  h1 {
    font-size: 5rem;
  }
}

.header-collapse {
  height: 100px;
}

.header-collapse h1 {
  font-size: 2.25rem;
  animation: gradient 0.25s linear;
}

@keyframes gradient {
  0% {
    background: linear-gradient(
      to left,
      #f06ca9,
      #f0608c,
      #ef3f50,
      #ed1e24,
      #f15d22,
      #f58120,
      #f78e1e,
      #f5a31f,
      #f5bd1e,
      #f5d01c,
      #f5de1a,
      #f5e719,
      #f5eb17,
      #e2de25,
      #b3c436,
      #6aa341 50%,
      #078e45,
      #23bdbd,
      #462e8d,
      #8b278a
    );
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  100% {
    background: linear-gradient(
      to right,
      #f06ca9,
      #f0608c,
      #ef3f50,
      #ed1e24,
      #f15d22,
      #f58120,
      #f78e1e,
      #f5a31f,
      #f5bd1e,
      #f5d01c,
      #f5de1a,
      #f5e719,
      #f5eb17,
      #e2de25,
      #b3c436,
      #6aa341 50%,
      #078e45,
      #23bdbd,
      #462e8d,
      #8b278a
    );
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

/*
instellingen voor opmaak
 */
main {
  margin: 0 auto;
  max-width: 81.25rem;
  min-width: 20rem;
  padding: 2rem 1.25rem 1.25rem;
  position: relative;
}

main::before {
  content: "";
  top: 0;
  left: 50%;
  height: 7.1875rem;
  width: 100vw;
  background-color: crimson;
  position: absolute;
  transform: translateX(-50%);
  z-index: -1;
}

.feature.col2 {
  box-shadow: 0 1.25rem 1.5rem 0 rgba(0, 0, 0, 0.1);
  position: relative;
}

.feature.col2 h3 {
  color: white;
  bottom: 1.25rem;
  font-family: neue-haas-unica, sans-serif;
  font-size: 1.25rem;
  padding: 0 1.25rem;
  position: absolute;
  text-shadow: 0 0 1px black;
  z-index: 3;
}

.feature.col1 {
  box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.08);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.feature.col1 h3 {
  font-family: neue-haas-unica, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  margin: 0.5rem 1rem 1.25rem;
}

.latest {
  margin-block-start: 1.875rem;
}

.latest h2 {
  color: crimson;
  font-family: neue-haas-unica, sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
}

.latest h3 {
  font-family: reset;
  font-weight: normal;
  font-size: 0.875rem;
  margin-block-end: 2rem;
}

.latest p {
  border-bottom: 1px solid crimson;
  display: inline-block;
  font-family: neue-haas-unica, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  margin-block-end: 0.25rem;
  text-transform: uppercase;
}

.latest article + p {
  border: none;
  display: block;
  font-family: neue-haas-unica, sans-serif;
  margin-block-end: 2.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  text-transform: none;
}

.latest article + p > a {
  color: crimson;
  text-decoration: none;
}

@media screen and (min-width: 960px) {
  .latest {
    margin-block-start: 0;
  }

  .latest h2 {
    color: white;
    font-size: 2.1875rem;
    line-height: 2.1875rem;
    margin-block-end: 1.5rem;
  }

  .latest article + p {
    text-align: initial;
  }
}

.trending {
  background-color: white;
  box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.08);
}

.trending h2 {
  background-color: crimson;
  color: white;
  font-family: neue-haas-unica, sans-serif;
  font-size: 2.1875rem;
  padding-block-end: 0.25rem;
  text-align: center;
}

.trending h3 {
  align-items: center;
  display: flex;
  font-family: neue-haas-unica, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.75rem;
}

.trending .number {
  align-items: center;
  border: 1px solid crimson;
  border-radius: 50%;
  color: crimson;
  display: flex;
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 700;
  height: 1.5rem;
  justify-content: center;
  margin-inline-end: 0.75rem;
  width: 1.5rem;
}

.trending .counter::before {
  counter-increment: trending-counter;
  content: counter(trending-counter);
}

.trending li + li {
  border-block-start: 1px solid hsl(0 0% 80%);
}

footer {
  align-items: center;
  background-color: black;
  display: flex;
  height: 30vh;
  justify-content: center;
}

footer h2 {
  color: white;
  font-family: "Zilla Slab", serif;
  font-size: 2.25rem;
  letter-spacing: 0.1rem;
}

              
            
!

JS

              
                function collapseHeader() {
  if (window.innerWidth > 959) {
    if (window.scrollY > 50) {
      pageHeader.classList.add("header-collapse");
    }
    if (window.scrollY < 50) {
      pageHeader.classList.remove("header-collapse");
    }
  }
}

const pageHeader = document.querySelector(".page-header");
window.addEventListener("scroll", collapseHeader);

              
            
!
999px

Console