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="recipe-card">
  <div id="recipe-card__cover" class="recipe-card__cover">
    <div class="recipe-card__img">
      <img
        src="https://images.unsplash.com/photo-1484723091739-30a097e8f929?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=687&q=80"
        alt="Blueberry French Toast">
    </div>
    <div class="recipe-card__cover-details">
      <div id="recipe-card__duration" class="recipe-card__duration">
        <p><span>30</span>mins</p>
      </div>
      <div id="recipe-card__servings" class="recipe-card__servings">
        <p><span>8</span>servings</p>
      </div>
      <div id="recipe-card__info" class="recipe-card__info">
        <div class="recipe-card__title">
          <h1>Blueberry French Toast</h1>
        </div>
        <div class="recipe-card__description">
          <p>Wonderful blueberry french toast recipe to serve for your whole family!</p>
        </div>
      </div>
    </div>
  </div>
    <div id="recipe-card__content-container" class="recipe-card__content-container">
    <div class="recipe-card__actions">
      <ul>
        <li><a id="ingredientsTab" href="#" class="active">Ingredients</a></li>
        <li><a id="preparationsTab" href="#">Preparation</a></li>
      </ul>
    </div>
    <div id="recipe-card__content--ingredients" class="recipe-card__content recipe-card__content--active">
      <ul>
        <span>MAIN:</span>
        <li> 12 slices day-old white bread, crusts removed</li>
        <li>2 packages (8 ounces each) cream cheese</li>
        <li>1 cup fresh or frozen blueberries</li>
        <li>12 large eggs, lightly beaten</li>
        <li>2 cups 2% milk</li>
        <li>1/3 cup maple syrup or honey</li>
      </ul>
      <ul>
        <span>SAUCE:</span>
        <li>1 cup sugar</li>
        <li>2 tablespoons cornstarch</li>
        <li>1 cup water</li>
        <li>1 cup fresh or frozen blueberries</li>
        <li>1 tablespoon butter</li>
      </ul>
    </div>
    <div id="recipe-card__content--preparations" class="recipe-card__content">
      <ul class="preparation-steps">
        <li>Cut bread into 1-in. cubes; place half in a greased 13x9-in. baking dish. Cut cream cheese into 1-in. cubes; place over bread. Top with blueberries and remaining bread cubes.</li>

        <li>Whisk the eggs, milk and syrup in a large bowl. Pour over bread mixture. Cover and refrigerate for 8 hours or overnight.</li>

        <li>Remove from the refrigerator 30 minutes before baking. Cover and bake at 350° for 30 minutes. Uncover; bake 25-30 minutes longer or until a knife inserted in center comes out clean.</li>

        <li>Combine the sugar, water and cornstarch until smooth in a small saucepan. Bring to a boil over medium heat; cook and stir until thickened, 3 minutes. Stir in blueberries; bring to a boil. Reduce heat and simmer until berries burst, 8-10 minutes. Remove from heat; stir in butter. Serve with French toast.</li>
      </ul>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  font-family: "Questrial", sans-serif;
}
.recipe-card {
  border-radius: 15px;
  display: flex;
  // background: #eee;
  &__cover {
    cursor: pointer;
    background:#EEE;
    border-radius: 15px;
    position: relative;
    height: 500px;
    width: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 30;
    transition: transform 0.3s ease-in-out, border-radius 0.3s ease-in-out;
    box-shadow: 0 2.8px 2.2px rgba(0, 0, 0, 0.02),
      0 6.7px 5.3px rgba(0, 0, 0, 0.028), 0 12.5px 10px rgba(0, 0, 0, 0.035),
      0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05),
      0 100px 80px rgba(0, 0, 0, 0.07);
    &-details {
      z-index: 20;
      color: white;
      height: 100%;
      width: 100%;
      position: relative;
    }
  }

  &__img {
    display: flex;
    position: absolute;
    z-index: 10;
    width: 100%;
    height: 100%;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center;
      transition: transform 0.3s ease-in;
    }
  }
  &__cover--open {
    transform: translateX(-80%);
    // border-top-right-radius: 0;
    // border-bottom-right-radius: 0;
  }
  &__cover:hover &__img {
    img {
      transform: scale(1.1);
    }
  }
  &__servings,
  &__duration {
    background: rgba(52, 73, 94, 0.8);
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 10px;
    text-align: center;
    font-size: 0.4em;
    transform: translatex(-120%);
    transition: transform 0.3s ease-in;
    text-transform: uppercase;
  }
  &__cover:hover &__servings,
  &__cover:hover &__duration {
    transform: translatex(0);
  }
  &__servings--show,
  &__duration--show {
    transform: translatex(0);
  }
  &__servings span,
  &__duration span {
    display: block;
    font-size: 3em;
  }
  &__info {
    position: absolute;
    bottom: 0;
    background: rgb(255, 255, 255);
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 25%,
      rgba(0, 0, 0, 0.6) 100%
    );
    padding: 0 20px;
    transition: transform 0.3s ease-in;
    transform: translateY(45%);
  }
  &__cover:hover &__info {
    transform: translateY(0%);
  }
  &__info--show {
    transform: translateY(0%);
  }
  &__title {
    font-family: "Enriqueta", serif;
    font-size: 1.2em;
  }
  &__description {
    font-size: 1.1em;
    line-height: 1.3;
  }
  &__content-container {
    width: 300px;
    height: 450px;
    margin-top:25px;
    background: #f5f5f5;
    position: absolute;
    box-shadow: 0 2.8px 2.2px rgba(0, 0, 0, 0.02),
      0 6.7px 5.3px rgba(0, 0, 0, 0.028), 0 12.5px 10px rgba(0, 0, 0, 0.035),
      0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05),
      0 100px 80px rgba(0, 0, 0, 0.07);
    transition: 0.3s ease-in-out ;
    border-radius: 15px;
    overflow: hidden;
  }
  &__content-container--open {
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
    transform: translateX(12%);
    width:500px;
  }
  &__actions {
    ul {
      padding: 0;
      margin: 0;
      list-style-type: none;
      display: flex;
      height: 60px;
      width: 100%;

      align-items: center;
    }
    li {
      display: flex;
      height: 60px;
      width: 100%;
      transition: background-color 0.2s ease;
      align-items: center;
      justify-content: center;
      position: relative;
    }
    li:hover {
      background-color: #eee;
    }

    a {
      padding: 10px;
      text-decoration: none;
      color: #333;
      text-transform: uppercase;
      border-bottom: 2px solid transparent;
      transition: border-bottom 0.2s ease;
      font-weight: 900;
    }
    a:hover {
      border-bottom: 2px solid #2c3e50;
    }
    a::after {
      content: "";
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
    }
    a.active {
      border-bottom: 2px solid #34495e;
    }
  }
  &__content {
    display: none;
    padding: 10px 20px;
    height: 360px;
    overflow-y: scroll;
    ul {
      list-style-type: none;
      padding: 0;
      margin: 0;
      display: flex;
      flex-direction: column;
      span {
        font-weight: 900;
        background: #34495e;
        color: white;
        padding: 5px 3px;
      }
    }
    li {
      min-height: 30px;
      display: flex;
      align-items: center;
      padding: 5px 3px;
      line-height: 1.4;
    }
    li:nth-child(even) {
      background: #eee;
    }
  }
  &__content--active {
    display: block;
  }
}

.preparation-steps{
  counter-reset: section;
}

.preparation-steps li{
  margin-left:10px;
  padding-left:30px;
  position:relative;
  border-left:3px solid rgba(52, 73, 94, .5);
}
.preparation-steps li::before{
  content:'1';
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  left:-21px;
  background: rgba(52, 73, 94, 1);
  color:white;
  border-radius:50%;
  height:2em;
  width:2em;
  display:flex;
  align-items:center;
  justify-content:center;
  border:4px solid #F5F5F5;
  counter-increment: section;
  content: counter(section);
}


@media screen and (max-width: 640px) {
  .recipe-card {
    flex-direction: column;
    &__cover {
      height: 50vh;
      width: 100vw;
      border-radius: 0;
      box-shadow: none;
    }
    &__cover--open,
    &__content-container--open {
      transform: translatex(0);
    }
    &__content-container {
      position: relative;
      height: 50vh;
      width: 100vw;
      border-radius:0;
      margin-top:0;
    }
    &__content{
      height:40vh;
      
    }
    &__info {
      transform: translateY(0);
    }
    &__duration {
      transform: translatex(0);
    }
    &__servings {
      transform: translatex(0);
    }
  }
}

              
            
!

JS

              
                const recipeCardCover = document.getElementById('recipe-card__cover');
const recipeCardInfo = document.getElementById('recipe-card__info');
const recipeCardDuration = document.getElementById('recipe-card__duration');
const recipeCardServings = document.getElementById('recipe-card__servings');
const recipeCardContentContainer = document.getElementById('recipe-card__content-container');
const ingredientsTab = document.getElementById('ingredientsTab');
const preparationsTab = document.getElementById('preparationsTab');
const ingredientsContent = document.getElementById('recipe-card__content--ingredients');
const preparationsContent = document.getElementById('recipe-card__content--preparations');

recipeCardCover.addEventListener('click', () => {
  recipeCardCover.classList.toggle('recipe-card__cover--open');
  recipeCardContentContainer.classList.toggle('recipe-card__content-container--open')
  recipeCardInfo.classList.toggle('recipe-card__info--show');
  recipeCardDuration.classList.toggle('recipe-card__duration--show');
  recipeCardServings.classList.toggle('recipe-card__servings--show');
})

ingredientsTab.addEventListener('click', (e) => {
  e.preventDefault();
  ingredientsTab.classList.add('active');
  preparationsTab.classList.remove('active');
  ingredientsContent.classList.add('recipe-card__content--active');
  preparationsContent.classList.remove('recipe-card__content--active');
})

preparationsTab.addEventListener('click', (e) => {
  e.preventDefault();
  ingredientsTab.classList.remove('active');
  preparationsTab.classList.add('active');
  ingredientsContent.classList.remove('recipe-card__content--active');
  preparationsContent.classList.add('recipe-card__content--active');
})
              
            
!
999px

Console