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

              
                <nav class="flex-nav">
  <div class="container">
    <div class="grid menu">
      <div class="column-xs-8 column-md-6">
        <p id="highlight">ShopShop</p>
      </div>
      <div class="column-xs-4 column-md-6">
        <a href="#" class="toggle-nav">Menu <i class="ion-navicon-round"></i></a>
        <ul>
          <li class="nav-item"><a href="#">Products</a></li>
          <li class="nav-item"><a href="#">About</a></li>
          <li class="nav-item"><a href="#">My Account</a></li>
          <li class="nav-item"><a href="#">Cart (0)</a></li>
        </ul>
      </div>
    </div>
  </div>
</nav>
<main>
  <div class="container">
    <div class="grid second-nav">
      <div class="column-xs-12">
        <nav>
          <ol class="breadcrumb-list">
            <li class="breadcrumb-item"><a href="#">Home</a></li>
            <li class="breadcrumb-item"><a href="#">Household Plants</a></li>
            <li class="breadcrumb-item active">Bonsai</li>
          </ol>
        </nav>
      </div>
    </div>
    <div class="grid product">
      <div class="column-xs-12 column-md-7">
        <div class="product-gallery">
          <div class="product-image">
            <img class="active" src="https://source.unsplash.com/W1yjvf5idqA">
          </div>
          <ul class="image-list">
            <li class="image-item"><img src="https://source.unsplash.com/W1yjvf5idqA"></li>
            <li class="image-item"><img src="https://source.unsplash.com/VgbUxvW3gS4"></li>
            <li class="image-item"><img src="https://source.unsplash.com/5WbYFH0kf_8"></li>
          </ul>
        </div>
      </div>
      <div class="column-xs-12 column-md-5">
        <h1>Bonsai</h1>
        <h2>$19.99</h2>
        <div class="description">
          <p>The purposes of bonsai are primarily contemplation for the viewer, and the pleasant exercise of effort and ingenuity for the grower.</p>
          <p>By contrast with other plant cultivation practices, bonsai is not intended for production of food or for medicine. Instead, bonsai practice focuses on long-term cultivation and shaping of one or more small trees growing in a container.</p>
        </div>
        <button class="add-to-cart">Add To Cart</button>
      </div>
    </div>
    <div class="grid related-products">
      <div class="column-xs-12">
        <h3>You may also like</h3>
      </div>
      <div class="column-xs-12 column-md-4">
        <img src="https://source.unsplash.com/miziNqvJx5M">
        <h4>Succulent</h4>
        <p class="price">$19.99</p>
      </div>
      <div class="column-xs-12 column-md-4">
        <img src="https://source.unsplash.com/2y6s0qKdGZg">
        <h4>Terranium</h4>
        <p class="price">$19.99</p>
      </div>
      <div class="column-xs-12 column-md-4">
        <img src="https://source.unsplash.com/6Rs76hNbIWE">
        <h4>Cactus</h4>
        <p class="price">$19.99</p>
      </div>
    </div>
  </div>
</main>
<footer>
  <div class="grid">
    <div class="column-xs-12">
      <p class="copyright">&copy; Copyright 2018 <a href="https://katherinekato.com" title="Katherine Kato"  target="_blank">Katherine Kato</a></p>
    </div>
  </div>
</footer>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Pontano+Sans');

$white: #fff;
$black: #333;
$lightergray: #d5d5d5;
$lightgray: #f0f3f1;
$gray: #e3dddd;
$text: #888;
$button: #3e3e3f;
$button-hover: #565657;

* {
  box-sizing: border-box;
  &::before, &::after {
    box-sizing: border-box;
  }
}

body {
  font-family: 'Pontano Sans', sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  color: $text;
  background: $white;
  text-rendering: optimizeLegibility;
}

ul {
  padding: 0;
  margin: 0;
  list-style: none;
  li {
    margin: 0 1.75rem 0 0;
  }
}

a {
  color: $text;
  text-decoration: none;
  transition: all 0.2s ease;
  &:hover {
    color: $black;
  }
  &.active {
    color: $black;
  }
}

h1, h2, h3, h4 {
  color: $black;
  font-weight: normal;
  margin: 1.75rem 0 1rem 0;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2.125rem;
  margin: 0;
}

h3 {
  font-size: 2rem;
}

h4 {
  font-size: 1.5rem;
  margin: 1rem 0 0.5rem 0;
}

section {
  display: block;
}

img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

nav {
  display: block;
  li {
    font-size: 1.125rem;
    margin: 0;
  }
}

.flex-nav ul {
  position: absolute;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  display: none;
  width: 100%;
  left: 0;
  padding: 1rem;
  background: $white;
  text-align: center;
  &.active {
    display: flex;
  }
  li {
    margin: 0.5rem 0;
  }
}

.toggle-nav {
  display: flex;
  justify-content: flex-end;
  font-size: 1.125rem;
  line-height: 1.7;
  margin: 1rem 0;
  i {
    font-size: 1.5rem;
    line-height: 1.4;
    margin: 0 0 0 0.5rem;
  }
}

#highlight {
  color: $black;
  font-size: 1.125rem;
  text-transform: uppercase;
}

.price {
  margin: 0;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 1rem 0 0 0;
  list-style: none;
  li {
    font-size: 0.85rem;
    letter-spacing: 0.125rem;
    text-transform: uppercase;
  }
}

.breadcrumb-item {
  &.active {
    color: $black;
  }
  + .breadcrumb-item {
    &::before {
      content: '/';
      display: inline-block;
      padding: 0 0.5rem;
      color: $lightergray;
    }
  }
}

.description {
  border-top: 0.0625rem solid $gray;
  margin: 2rem 0;
  padding: 1rem 0 0 0;
}

.add-to-cart {
  position: relative;
  display: inline-block;
  background: $button;
  color: $white;
  border: none;
  border-radius: 0;
  padding: 1.25rem 2.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;
  transform: translateZ(0);
  transition: color 0.3s ease;
  letter-spacing: 0.0625rem;
  &:hover {
    &::before {
      transform: scaleX(1);
    }
  }
  &::before {
    position: absolute;
    content: '';
    z-index: -1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: $button-hover;
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 0.3s ease-out;
  }
}

.container {
  margin: auto;
  padding: 0 1rem;
  max-width: 75rem;
  width: 100%;
}

.grid {
  > [class*="column-"] {
    padding: 1rem;
  }
  &.menu, &.product {
    border-bottom: 0.0625rem solid $gray;
  }
  &.menu {
    > [class*="column-"] {
      padding: 0.5rem 1rem 0.5rem 1rem;
    }
  }
  &.product {
    padding: 0 0 1.5rem 0;
  }
  &.second-nav {
    > [class*="column-"] {
      padding: 0.5rem 1rem;
    }
  }
}

footer {
  padding: 1rem 0;
  text-align: center;
}

.product-image {
  display: none;
}

.image-list {
  li {
    margin: 0;
  }
}

@media (min-width: $md) {
  .product-image img, .image-list img {
    width: 100%;
  }

  .product-image {
    display: block;
    img {
      height: 52vh;
      &.active {
        display: block;
        margin: 0 0 0.75rem 0;
      }
    }
  }
  
  .image-list {
    display: flex;
    overflow: hidden;
    li {
      margin: 0 0.75rem 0 0;
      flex-basis: 100%;
      &:nth-child(3) {
        margin: 0;
      }
    }
    img {
      height: 10rem;
      width: 100%;
      transition: opacity 0.3s ease;
      cursor: pointer;
      &:hover {
        opacity: 0.7;
      }
    }
  }

  nav ul {
    justify-content: flex-end;
  }

  .toggle-nav {
    display: none;
  }

  .flex-nav {
    display: block;
    ul {
      display: flex;
      flex-direction: row;
      position: relative;
      justify-content: flex-end;
      li {
        font-size: 1.125rem;
        margin: 0 1.5rem 0 0;
        &:nth-child(4) {
          margin: 0;
        }
      }
    }
  }
}

@keyframes fadeImg {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
              
            
!

JS

              
                const activeImage = document.querySelector(".product-image .active");
const productImages = document.querySelectorAll(".image-list img");
const navItem = document.querySelector('a.toggle-nav');

function changeImage(e) {
  activeImage.src = e.target.src;
}

function toggleNavigation(){
  this.nextElementSibling.classList.toggle('active');
}

productImages.forEach(image => image.addEventListener("click", changeImage));
navItem.addEventListener('click', toggleNavigation);
              
            
!
999px

Console