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

              
                <div class="wrapper" id="wrapper">
  <div class="cover page" id="cover">
    <h1>Recipes Shmecipes</h1>
    <h2>Mary Berrys, Banana Bread</h2>
    <p>A warming banana loaf recipe, made using the ripest bananas. This deliciously moist loaf cake, best served in thick slices, is one of Mary Berry's most popular recipes.</p>
  </div>
  <img class="image" src="https://i.pinimg.com/564x/a5/f0/2b/a5f02b5d0feacbd33d382bd979ac92ea.jpg" alt="yummy">
  <div class="intro" id="intro">
    <h3>Intro</h3>
    <p>This is a lovely, moist loaf, which really doesn’t need to be buttered. It freezes extremely well. Any bananas left in the fruit bowl are ideal for this cake - the riper they are, the better.</p>
    <ul class="stats">
      <li class="level stat">Level: <span>Easy</span></li>
      <li class="prep stat">Prep Time: <span>15min</span></li>
      <li class="cook stat">Cook Time: <span>1hr</span></li>
      <li class="total stat">Total time: <span>1.15hr</span></li>
    </ul>
  </div>
  <div class="ingredients" id="ingredients">
    <h3>Ingredients</h3>
    <div class="ingredient">
      <p class="ingredient--amount">100g</p>
      <p>butter, softend</p>
    </div>
    <div class="ingredient">
      <p class="ingredient--amount">175g</p>
      <p>caster sugar</p>
    </div>
    <div class="ingredient">
      <p class="ingredient--amount">2</p>
      <p>eggs</p>
    </div>
    <div class="ingredient">
      <p class="ingredient--amount">2</p>
      <p>ripe bananas, mashed</p>
    </div>
    <div class="ingredient">
      <p class="ingredient--amount">1 tsp</p>
      <p>baking powder</p>
    </div>
  </div>
  <div class="kit" id="kit">
    <h3>Essential Kit</h3>
    <p>You will need a 900g (2lb) loaf tin, 17 x 9 x 9cm (6½ x 3½ x 3½in) base measurement.</p>
  </div>
  <div class="instructions " id="instructions">
    <h3>Instructions</h3>
    <p class="step step--1">Lightly grease the loaf tin and line it with non-stick baking parchment. Pre-heat the oven to 180°C/350°F/Gas Mark 4. Measure all the ingredients into a mixing bowl and beat for about 2 minutes, until well blended; an electric mixer is best for this but of course you can also beat by hand with a wooden spoon.</p>
    <p class="step step--2">Spoon the mixture into the prepared tin and level the surface. Bake for about 1 hour, until well risen and golden brown. A fine skewer inserted in the centre of the cake should come out clean.</p>
    <p class="step step--3">Leave the cake to cool in the tin for a few minutes, then loosen with a small palette knife and turn the cake out. Remove the lining paper and leave on a wire rack to cool completely. Slice thickly to serve.</p>
  </div>
</div>
              
            
!

CSS

              
                body {
background: #ee9ca7;  /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #ffdde1, #ee9ca7);  /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #ffdde1, #ee9ca7); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */

  height: 100vh;
  font-family: 'Rubik', sans-serif;
}

.wrapper {
  width: 375px;
  height: 600px;
  background: white;
  overflow: hidden;
  margin: 4em auto;
  position: relative;
  box-shadow: 15px 14px 12px -12px rgba(77,76,77,1);
}

  h3 {
    font-family: "Abril Fatface", cursive;
  }

.page {
  position: absolute;
  z-index: 2;
  padding: 0 2em;
  top: 0;
  height: 600px;
  max-width:100%;
  
}
h3 {
  padding-bottom: 1em;
  border-bottom: 4px solid rgba(143, 215, 229, 1);
}
.cover {
  z-index: 1;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to bottom, transparent 70%,  rgba(143, 215, 229, 0.75) 45%);

  h1 {
    font-family: "Abril Fatface", cursive;
    position: absolute;
    top: 0;
    display: flex;
    width: 100%;
    justify-content: center;
  }
  
  h2 {
    display: block;
    position: absolute;
    bottom: 20%;
    color: white;
    padding: 0.3em 0;
    margin-bottom: 0;
  }
  
  p {
    margin-top: - 20px;
    color: white;
  }
}

.image {
  position: absolute;
  width: 100%;
  top: 0;
}

.intro {
  height: 110%;
  background: white;
  padding-top: 20px;
}

.stats {
  margin-top: 2em;
  padding: 0;
}
.stat {
  list-style: none;
  display: grid;
  align-items: center;
  margin-bottom: 20px;
  grid-template-columns: 0.1fr 0.7fr 1fr;
  justify-content: left;
  font-weight: 600;
  color: rgba(143, 215, 229, 1);
  padding-bottom: 1em;
  padding-top: 1em;
  
  
  span {
    font-weight: 400;
    color: black;
  }
 
  &::before {
    height: 25px;
    width: 25px;
    content: '';
    display: inline-block;
    margin-right: 1em;
  }

}
  .level {
    &::before {
      content: url('https://img.icons8.com/color/25/000000/chef-hat.png');
    }
  }
.prep {
  &::before {
    content: url('https://img.icons8.com/dusk/25/000000/knife.png');
  }
}

.cook {
  &::before {
    content: url('https://img.icons8.com/ultraviolet/25/000000/cooker.png');
  }
}

.total {
  &::before {
    content: url('https://img.icons8.com/ultraviolet/25/000000/time.png');
  }
}

.ingredients {
  background: white;
  width: 100%;
  padding: 0;
  
  h3 {
    margin: 2em;
  }
  
  .ingredient {
    display: grid;
    grid-template-columns: 0.3fr 1fr;
    grid-column-gap: 3em;
    margin: 0 2em;
    
    p {
      align-self: center;
    }
    
    &--amount {
      background-color: #90d7e5;
      padding: 0.5em;
      display: flex;
      align-items: center;
      text-align: center;
      font-weight: 800;
      display: inline-block;
      border-radius: 15px;
      color: white;
    }
  }
}

.kit {
  background: white;
  
  h3 {
       margin: 2em 0;
  }
}

.instructions {
  background: white;
  
  h3 {
       margin: 2em 0;
  }
  
}
              
            
!

JS

              
                const pages = ["cover", "intro", "ingredients", "kit", "instructions"];

const element = document.getElementById("wrapper");

document.onclick = inputChange;

function inputChange(e) {
  const pageWidth = element.clientWidth;
  const leftHand = pageWidth / 2;
  const clickLocation = e.clientX;
    const currentPage = pages.find(function(element, index) {
      if (document.getElementById(element).matches(".page")) {
        return element
      }
    });
    const nextPage = pages.indexOf(currentPage) + 1;
    const previousPage = pages.indexOf(currentPage) - 1;
  
  if (clickLocation >= leftHand) {
    if(pages.indexOf(currentPage) < pages.length - 1) {
      document.getElementById(currentPage).classList.remove('page')
      document.getElementById(pages[nextPage]).classList.add('page')
    }
    console.log("Right Click");
    
  } 
  
  else if (clickLocation < leftHand) {
    console.log("Left");
    if(pages.indexOf(currentPage) > 0 ) {
      document.getElementById(currentPage).classList.remove('page')
    document.getElementById(pages[previousPage]).classList.add('page')
    }
    


  }
}

//     pages.some(function(element, index) {

//       if (document.getElementById(element).matches(".page")) {
//         if (index < pages.length - 1 ) {
//          document.getElementById(element).classList.remove('page')
//          document.getElementById(pages[index + 1]).classList.add('page')

//          console.log(element, 'ran')
//         }

//         else {
//           console.log('end')
//         }
//       }

//     });

              
            
!
999px

Console