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

              
                <a id="slide-1" title="slide 1" class="slide"></a>
<a id="slide-2" title="slide 2" class="slide"></a>
<a id="slide-3" title="slide 3" class="slide"></a>

<nav class="nav" aria-label="table of contents">
 <ul class="nav__list">
  <li class="nav__item">
   <a href="#slide-1" title="slide 1" accesskey=1 class="nav__link"> </a>
  </li>
  <li class="nav__item">
   <a href="#slide-2" title="slide 2" accesskey=2 class="nav__link"></a>
  </li>
  <li class="nav__item">
   <a href="#slide-3" title="slide 3" accesskey=3 class="nav__link"></a>
  </li>
 </ul>
</nav>

<main role="main" class="main">
 <section class="main__slide main__slide-1" data-slide="1">
  <div class="grid__text grid__item" data-grid="i1">
   <h1>Americano</h1>
   <hr>
   <p>White, spoon wings french press aromatic black cappuccino.</p>
  </div>
  <p class="grid__text grid__item" data-grid="i2">
    Filter, body breve sit coffee, turkish aromatic spoon crema turkish caffeine strong. As single origin extra, carajillo mug, aftertaste con panna, extraction roast galão grounds medium. That saucer cinnamon cortado decaffeinated caramelization seasonal.
   </p>
   <div class="grid__image grid__item" data-grid="i4"></div>
   <h3 class="grid__text grid__item" data-grid="i5">
    Opening times
   </h3>
	 <p class="grid__text grid__item" data-grid="i3">
    10:00
   </p>
   <div class="grid__image grid__item" data-grid="i6"></div>
   <div class="grid__image grid__item" data-grid="i7"></div>
   <div class="grid__image grid__item" data-grid="i8"></div>
   <div class="grid__text grid__item" data-grid="i9">
    <h4>Cappuccino</h4>
     <p>Java robusta so filter percolator crema chicory caramelization barista. Beans shop bar organic so mazagran lungo.</p>
   </div>
 </section>

 <section class="main__slide main__slide-2" data-slide="2">
  <h1 class="grid__text grid__item" data-grid="7">Espresso</h1>
  <p class="grid__text grid__item" data-grid="6">Trifecta coffee, aromatic robust strong breve dripper aromatic white brewed variety extra.</p>
  <h2 class="grid__text grid__item" data-grid="8">Cappucino</h2>
  <p class="grid__text grid__item" data-grid="9">In caffeine caramelization redeye, dark galão milk sit sweet.</p>
  <h3 class="grid__text grid__item" data-grid="10">Americano</h3>
  <div class="grid__image grid__item" data-grid="2"></div>
  <div class="grid__image grid__item" data-grid="1"></div>
  <div class="grid__image grid__item" data-grid="3"></div>
  <div class="grid__image grid__item" data-grid="4"></div>
  <div class="grid__image grid__item" data-grid="5"></div>
 </section>

 <section class="main__slide main__slide-3" data-slide="3">
  <h1 class="grid__text grid__item grid__heading grid__heading--big" data-grid="3">Coffee</h1>
  <h1 class="grid__text grid__item grid__heading" data-grid="4">Café au lait</h1>
  <p class="grid__text grid__item" data-grid="5">Dripper grounds blue mountain, at con panna, black filter barista wings french press. Grounds french press latte instant, siphon cinnamon spoon instant coffee. Lungo as half and half body, spoon siphon lungo pumpkin spice dark. Sit, mocha, spoon dripper
   white that, café au lait sweet aromatic iced grounds. </p>
  <p class="grid__text grid__item" data-grid="6">Flavour, aromatic caffeine ristretto as single origin brewed. Spoon crema arabica steamed sweet americano brewed siphon. Bar, that ut coffee froth mazagran french press shop java mug rich. Espresso variety mocha cappuccino frappuccino rich seasonal.
   </p>
  <p class="grid__text grid__item" data-grid="7">Frappuccino body ut cream qui doppio, blue mountain est grounds crema shop.</p>
  <div class="grid__image grid__item" data-grid="1"></div>
  <div class="grid__image grid__item" data-grid="2"></div>
 </section>
</main>
              
            
!

CSS

              
                $slide-count: 3;
$colors: ("#FF7043", "#FFA726", "#FFCA28", "#FFEE58", "#D4E157");
$images: (
  "https://source.unsplash.com/I_394sxx0ec/600x600",
  "https://source.unsplash.com/ZUUsGnG5zwc/600x600",
  "https://source.unsplash.com/QKylkd3HS6o/600x600",
  "https://source.unsplash.com/dqpEg5lo9P0/600x600",
  "https://source.unsplash.com/pJn9WhMqFIs/600x600",
  "https://source.unsplash.com/8UE83jPlNXg/600x600"
);
$easing: cubic-bezier(0.2, 0, 0.5, 1);

html, body {
  height: 100%;
  width: 100%;
}

body {
	color: #fff;
  font-family: 'Montserrat', Merriweather, Georgia, serif;
	background: #282F3A;
}

/*
* Main CSS 
*/
.main {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  
  &__slide {
    position: absolute;
    width: 100%;
    top: 50%;
    left: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transform-origin: 50% 50%;
    transition: opacity 350ms ease-in-out;
  }
}

/*
* Navigation
*/
.nav {
  position: fixed;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  display: block;
  z-index: 2;
  
  &__list {
    margin: 0;
    padding: 0;
  }
  
  &__item {
    display: block;
    margin: 0 auto 1rem;
  }
  
  &__link {
    display: block;
    position: relative;
    width: 25px;
    height: 25px;
    margin: 0 auto;
    border-radius: 50%;
  }
}

.slide {
  position: absolute;
}

/*
* CSS Variables
*/
.main__slide {
  --visible: 0;
  --gap: 20px;
  opacity: var(--visible, 0);
	pointer-events: none;
}

// set variable on parent
.nav__item {
  --background: unquote(nth($colors, 1));
}

// set background with inhereted variable
.nav__link {
  background: teal;
}


/*
* Loops for slides
*/
@for $i from 1 through $slide-count {
  // show and hide slide according to selection
  #slide-#{$i} {
    &:target ~ .main {
			.main__slide[data-slide] {
				--visible: 0;
			}
		
      .main__slide[data-slide=#{"'"+ $i + "'"}] {
        --visible: 1;
        pointer-events: all;
      }
    }
  }
  // color the dots
  .nav__item:nth-child(#{$i}) {
    --background: unquote(nth($colors, $i));
  }
}

/*
* Main grid things 
*/
.main__slide {
  display: grid;
  grid-gap: var(--gap);
	
	&-1 {
		--visible: 1;
		pointer-events: all;
	}
}

.grid__image {
  background: #f2f2f2;
  background-size: cover;
  background-position: 50% 50%;
  width: 100%;
  z-index: -1;
  margin: 0;
	-webkit-backface-visibility: hidden; 
	backface-visibility: hidden;
}

.grid__text {
  margin: 0;
}

/*
* Grid Slide 1
*/
$grid-images: ("i4", "i6", "i7", "i8");

.main__slide-1 {
  --gap: 2px;
  width: calc(100% - 10em);
  height: calc(100% - 5em);
  
  grid-template-columns: 2fr 2fr 2fr 1fr 2fr;
  grid-template-rows: 3fr 1fr 1fr 2fr;
  grid-template-areas:
    'i1 i1 i1 i2 i2 i2'
    'i1 i1 i1 i3 i4 i4'
    'i5 i5 i5 i9 i9 i9'
    'i6 i7 i8 i9 i9 i9';
  justify-items: stretch;
  align-items: stretch;
  
  background: #F0F0EE;
  color: #222;
  border-radius: 10px;
  
  .grid__item {
    box-shadow: 0 0 0 2px #222;
    padding: 2em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
	
	.grid__image {
		filter: grayscale(100%);
		transition: filter 0.4s ease-in-out;
		
		&:hover {
			filter: grayscale(0%);
		}
	}
  
  @for $i from 1 through 9 {
    .grid__item[data-grid=#{"'i"+ $i + "'"}] {
      grid-area: unquote("i" + $i);
    }
  }
	
	@for $i from 1 through length($grid-images) {
  	.grid__image[data-grid=#{nth($grid-images, $i)}] {
     	background-image: url(#{ nth($images, $i) });
    }
	}

}

/*
* Grid Slide 2
*/
$grid-2-items: (
  "1 / 1 / 3 / 5",
  "1 / 7 / 5 / 9",
  "3 / 1 / 5 / 5",
  "5 / 1 / 9 / 3",
  "5 / 5 / 7 / 9",
  "1 / 4 / 5 / 6",
  "4 / 5 / 5 / 9",
  "5 / 1 / 6 / 5",
  "5 / 4 / 9 / 6",
  "8 / 7 / 9 / 8",
);

$grid-clipping: (
  "polygon(50% 100%, 0 0, 100% 0);",
  "polygon(100% 100%, 0 50%, 100% 0);",
  "polygon(50% 0%, 0% 100%, 100% 100%);",
  "polygon(0 100%, 100% 50%, 0 0)",
  "polygon(50% 100%, 0 0, 100% 0);",
);

.main__slide-2 {
  --gap: 0px;
  width: calc(100% - 6em);
  max-width: 450px;
  height: calc(100vh - 6em);
  
  border-radius: 1em;
  background: #EEEFEE;
  overflow: hidden;
  
  grid-auto-rows: calc(100vh / 9);
  grid-auto-columns: calc(100% / 8);
  
  justify-content: center;
  align-content: center;
  
  .grid__image {
    filter: grayscale(100%);
    transition: filter 0.3s $easing;
    
    &:hover {
      filter: grayscale(0%);
    }
  }
  
  .grid__text {
    color: #222;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
  }

	@for $i from 1 through 10 {
		.grid__item[data-grid=#{"'"+ $i + "'"}] {
			grid-area: unquote(nth($grid-2-items, $i));
		}
	}
	
	@for $i from 1 through 5 {
    .grid__image[data-grid=#{"'"+ $i + "'"}] {
      background-image: url(#{ nth($images, $i) });
      clip-path: unquote(nth($grid-clipping, $i));
    }
  }
}

/*
* Grid Slide 3
*/
$grid-3-items: (
  "5 / 4 / 10 / 9",
  "7 / 12 / 9 / 15",
  "1 / 1 / 3 / 17",
  "4 / 10 / 5 / 15",
  "9 / 3 / 13 / 6",
  "7 / 8 / 12 / 11",
  "11 / 13 / 13 / 16",
);

.main__slide-3 {
  --gap: 0px;
  --items: 16;
  width: calc(100% - 6em);
  
  grid-auto-rows: calc(100vh / var(--items));
  grid-auto-columns: calc(100% / var(--items));
  
  .grid__text {
    text-shadow: 0px 0px 25px #000;
    line-height: 1.2;
    font-family: 'Lora', Merriweather, Georgia, serif;
  }
  
  .grid__heading {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Montserrat', Merriweather, Georgia, serif;
    
    &--big {
      opacity: 0.6;
      letter-spacing: 1em;
      font-size: 5em;
    }
  }
  
  .grid__image {
    filter: saturate(30%);
    transition: filter 0.4s $easing;
    
    &:hover {
      filter: saturate(100%);
    }
  }
	
	@for $i from 1 through 7 {
    .grid__item[data-grid=#{"'"+ $i + "'"}] {
      grid-area: unquote(nth($grid-3-items, $i));
    }
  }
  
  @for $i from 1 through 2 {
    .grid__image[data-grid=#{"'"+ $i + "'"}] {
      background-image: url(#{ nth($images, $i) });
    }
  }
}

// media query

@media only screen and (max-width: 768px) {
  .main {
    position: static;
    width: 100%;
    height: 100%;
    
    &__slide {
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      
			width: 90%;
      margin: 5%;
      height: fit-content;
      overflow: visible;
      max-width: 100%;
      padding: 10px;
      
      left: 0;
      top: 0;
      transform: none;
    }
  }
  
	.grid {
		&__image {
				padding-top: 50%;
				width: 50%;
				margin: 5px auto;
				z-index: 1;
		}
		
		&__item[data-grid] {
			box-shadow: none;
			margin: 0.5em auto;
		}
	}
  
  // individual slides
  .main__slide-2 .grid__image[data-grid] {
    clip-path: none;
  }
}
              
            
!

JS

              
                // no JS, CSS can do it all!
              
            
!
999px

Console