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

              
                <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
        <link rel="stylesheet" href="css/all.css">
        <link rel="stylesheet" href="css/style.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
        <link href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&display=swap" rel="stylesheet">
        <title>The Yellow Cafe</title>
    </head>
    
    <body>
      <header>
        <nav class="navbar navbar-expand-lg px-4" style="font-size:25px;">
          <a class="navbar-brand"></a>
          <button class="navbar-toggler" data-toggle="collapse" href="myNav" role="button" type="button" >
            <span class="toggler-icon"><i class="fas fa-bars"></i></span>
          </button>
          <div class="collapse navbar-collapse" id="myNav">
            <ul class="navbar-nav mx-auto text-capitalize">
              <li class="nav-item active">
                <a class="nav-link" style="font-size:35px;" href="#">home</a>
              </li>
              <li class="nav-item">
                <a class="nav-link " style="font-size:35px;" href="#about">about</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" style="font-size:35px;" href="#store">store</a>
              </li>
            </ul>
            <div class="nav-info-items d-none d-lg-flex ">
             <div class="nav-info align-items-center d-flex justify-content-between mx-lg-5">
                <span class="info-icon mx-lg-3"><i class="fas fa-phone"></i></span>
                <p class="mb-0">+ 123 456 789</p>
              </div>
           
              <div id="cart-info" class="nav-info align-items-center cart-info d-flex justify-content-between mx-lg-5">
                <span class="cart-info__icon mr-lg-3"><i class="fas fa-shopping-cart"></i></span>
                <p class="mb-0 text-capitalize"><span id="item-count">2 </span> items - $<span class="item-total">10.49</span></p>
              </div>
             
            </div>
          </div>
        </nav>
     
        <div class="container-fluid">
          <div class="row max-height justify-content-center align-items-center">
            <div class="col-10 mx-auto banner text-center">
              <h1 class="text-capitalize">welcome to <strong class="banner-title ">the yellow cafe</strong></h1>
              <a href="#store" class="btn banner-link text-uppercase my-2">explore</a>
    
            </div>
            <div id="cart" class="cart">
            
              <div class="cart-total-container d-flex justify-content-around text-capitalize mt-5">
                <h5>total</h5>
                <h5> $ <strong id="cart-total" class="font-weight-bold"></strong> </h5>
              </div>
            
              <div class="cart-buttons-container mt-3 d-flex justify-content-between">
                <a href="#" id="clear-cart" class="btn btn-outline-secondary btn-black text-uppercase">clear cart</a>
                <a href="#" class="btn btn-outline-secondary text-uppercase btn-pink">checkout</a>
              </div>
            </div>
          </div>
        </div>
      </header>
     
      <section class="about py-5" id="about">
        <div class="container">
    
          <div class="row">
            <div class="col-10 mx-auto col-md-6 my-5">
              <h1 class="text-capitalize">about <strong class="banner-title ">us</strong></h1>
              <p class="my-4 text-muted w-75">Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit, aliquam voluptas
                beatae vitae expedita consectetur nesciunt quia deserunt asperiores facere fuga dicta fugiat corrupti et omnis
                porro at dolorum! Ad!</p>
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase ">explore</a>
    
            </div>
            <div class="col-10 mx-auto col-md-6 align-self-center my-5">
              <div class="about-img__container">
                <img src="img/abundance-1868573__480.jpg" class="img-fluid" alt="">
              </div>
            </div>
          </div>
        </div>
      </section>


      <section id="store" class="store py-5">
        <div class="container">

          <div class="row">
            <div class="col-10 mx-auto col-sm-6 text-center">
              <h1 class="text-capitalize">our <strong class="banner-title ">store</strong></h1>
            </div>
          </div>
         
          <div class="row">
            <div class=" col-lg-8 mx-auto d-flex justify-content-around my-2 sortBtn flex-wrap">
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase filter-btn m-2" data-filter="all"> all</a>
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase filter-btn m-2" data-filter="cakes">coffee</a>
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase filter-btn m-2" data-filter="cupcakes">smoothies</a>
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase filter-btn m-2" data-filter="sweets">breakfast</a>
              <a href="#" class="btn btn-outline-secondary btn-black text-uppercase filter-btn m-2" data-filter="doughnuts">sweets</a>
            </div>
          </div>
    
          <div class="row">
            <div class="col-10 mx-auto col-md-6">
              <form>
                <div class="input-group mb-3">
                  <div class="input-group-prepend ">
                    <span class="input-group-text search-box" id="search-icon"><i class="fas fa-search"></i></span>
                  </div>
                  <input type="text" class="form-control" placeholder='item....' id="search-item">
                </div>
              </form>
            </div>
          </div>
      
          <div class="row" class="store-items" id="store-items">
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item sweets" data-item="sweets">
              <div class="card ">
                <div class="img-container">
                  <img src="img/coffee-983955__480.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">latte</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">5</strong></h5>
                  </div>
                </div>
              </div>
            </div>
           
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item cupcakes" data-item="cupcakes">
              <div class="card ">
                <div class="img-container">
                  <img src="img/green-2607334_1920.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">green smoothie</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">5</strong></h5>
                  </div>
                </div>
              </div>
            </div>
         
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item cakes" data-item="cakes">
              <div class="card ">
                <div class="img-container">
                  <img src="img/coffee-4334647__480.webp" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">espresso</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">5</strong></h5>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item doughnuts" data-item="dougnuts">
              <div class="card ">
                <div class="img-container">
                  <img src="img/cupcakes-5116009__480.webp" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">mocha cupcakes</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">5</strong></h5>
                  </div>
                </div>
              </div>
            </div>
          
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item sweets" data-item="sweets">
              <div class="card ">
                <div class="img-container">
                  <img src="img/food-2569257__480.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">breakfast bowl meal</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">10</strong></h5>
                  </div>
                </div>
              </div>
            </div>
           
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item cupcakes" data-item="cupcakes">
              <div class="card ">
                <div class="img-container">
                  <img src="img/breakfast-690128__480.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">family breakfast combo</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">10</strong></h5>
                  </div>
                </div>
              </div>
            </div>
          
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item cakes" data-item="cakes">
              <div class="card ">
                <div class="img-container">
                  <img src="img/abundance-1868573__480.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">bakery items</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">10</strong></h5>
                  </div>
                </div>
              </div>
            </div>
         
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item doughnuts" data-item="dougnuts">
              <div class="card ">
                <div class="img-container">
                  <img src="img/food-2673724_1920.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">avacado toast</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">10</strong></h5>
                  </div>
                </div>
              </div>
            </div>
         
            <div class="col-10 col-sm-6 col-lg-4 mx-auto my-3 store-item sweets" data-item="sweets">
              <div class="card ">
                <div class="img-container">
                  <img src="img/acai-bowl-4935771_1920.jpg" class="card-img-top store-img" alt="">
                  <span class="store-item-icon">
                    <i class="fas fa-shopping-cart"></i>
                  </span>
                </div>
                <div class="card-body">
                  <div class="card-text d-flex justify-content-between text-capitalize">
                    <h5 id="store-item-name">smoothie bowl</h5>
                    <h5 class="store-item-value">$ <strong id="store-item-price" class="font-weight-bold">15</strong></h5>
                  </div>
                </div>    
              </div>        
            </div>
          </div>
      </section>
   
      <div class="container-fluid ">
        <div class="row lightbox-container align-items-center">
          <div class="col-10 col-md-10 mx-auto text-right lightbox-holder">
            <span class="lightbox-close"><i class="fas fa-window-close"></i></span>
            <div class="lightbox-item"></div>
            <span class="lightbox-control btnLeft"><i class="fas fa-caret-left"></i></span>
            <span class="lightbox-control btnRight"><i class="fas fa-caret-right"></i></span>
          </div>
        </div>
      </div>
    
    
      <script src="js/jquery-3.3.1.min.js"></script>
      <script src="js/app.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</body>
</html>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&display=swap");

:root {
  --mainOrange: #E2532F;
  --mainYellow: #DDA033;
  --mainWhite: #E0D8C3;
  --mainBlue: #0D97AC;
  --yellowTrans: rgba(249, 228, 148, 0.5);
  --mainGrey: rgb(238, 238, 238);
}

body {
  font-family: 'Amatic SC', cursive;
  background: var(--mainWhite);
  color: var(--mainYellow);
}
.navbar-toggler {
  outline: none !important;
}
.toggler-icon {
  font-size: 2.5rem;
  color: var(--mainBlue);
}
.nav-link {
  color: var(--mainBlue);
  font-size: 1.5rem;
  transition: all 0.5s ease-in-out;
}
.nav-link:hover {
  color: var(--mainYellow);
}

.cart-info__icon {
  color: var(--mainBlue);
  cursor: pointer;
}

.cart-info {
  border: 0.1rem solid var(--mainBlue);
  color: var(--mainBlue);
  border-radius: 0.25rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.cart-info:hover {
  background: var(--mainYellow);
  border-color: var(--mainBlue);
  color: var(--mainWhite);
}
.cart-info:hover .cart-info__icon {
  color: var(--mainWhite);
}

.max-height {
  min-height: calc(100vh - 76px);
  background: linear-gradient(var(--yellowTrans), var(--yellowTrans)),
    url("../img/headerBcg.jpeg") center/cover fixed no-repeat;
  position: relative;
}

.container-fluid {
  background-image: url("../img/flower-5459972_1920\ \(1\).jpg");
  background-size: cover;
}
.banner {
  color: var(--mainWhite);
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: #000;
  font-size: 100px;
  
}
.banner-title {
  color: var(--mainWhite);
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: #000;
  font-size: 100px;
  
}
.banner-link {
  font-size: 1.5rem;
  color: var(--mainBlue);
  border: 0.2rem solid var(--mainBlue);
}
.banner-link:hover {
  background: var(--mainBlue);
  color: var(--mainYellow);
}

.cart {
  position: absolute;
  min-height: 10rem;
  background: var(--mainWhite);
  top: 0;
  right: 0;
  transition: all 0.3s ease-in-out;
  background: rgba(255, 255, 255, 0.5);
  width: 0;
  overflow: hidden;
}
.show-cart {
  width: 18rem;
  padding: 2rem 1.5rem;
  transform: rotateY(-360deg);
}
.cart-item {
  transition: all 2s ease-in-out;
}

.cart-item-remove {
  color: var(--mainOrange);
  transition: all 1s ease-in-out;
}
.cart-item-remove:hover {
  transform: scale(1.1);
  color: var(--mainBlue);
}
#cart-item-price {
  font-size: 0.8rem;
}

.btn-orange {
  color: var(--mainOrange) !important;
  border-color: var(--Orange) !important;
}
.btn-blue {
  color: var(--mainBlue) !important;
  border-color: var(--mainBlue) !important;
}
.btn-blue:hover {
  color: var(--mainYellow) !important;
  background: var(--mainBlue) !important;
}
.btn-orange:hover {
  background: var(--mainOrange) !important;
  color: var(--mainBlue) !important;
}

.about-img__container {
  position: relative;
}

.about-img__container::before {
  content: "";
  position: absolute;
  top: -1.5rem;
  left: -1.7rem;
  width: 100%;
  height: 100%;
  outline: 0.5rem solid var(--mainYellow);
  z-index: -1;
  transition: all 1s ease-in-out;
}
.about-img__container:hover:before {
  top: 0;
  left: 0;
}

.store {
  background: var(--mainGrey);
}
.img-container {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.store-img {
  transition: all 1s ease-in-out;
}
.img-container:hover .store-img {
  transform: scale(1.2);
}
.store-item-icon {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 0.75rem;
  background: var(--mainBlue);
  border-top-left-radius: 1rem;
  transition: all 1s ease-in-out;
  transform: translate(100%, 100%);
}
.img-container:hover .store-item-icon {
  transform: translate(0, 0);
}
.store-item-icon:hover {
  color: var(--mainWhite);
}
.store-item-value {
  color: --mainYellow;
}

.search-box {
  background: var(--mainYellow);
  color: var(--mainBlue);
}

.lightbox-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.6) !important;
  display: none;
}
.show {
  display: block;
}

.lightbox-holder {
  position: relative;
}
.lightbox-item {
  min-height: 80vh;
  background: url("../img/cake-1.jpeg") center/cover fixed no-repeat;
  border-radius: 0.3rem;
}
.lightbox-close {
  color: var(--mainOrange);
  font-size: 3rem;
  transition: all 1s ease-in-out;
  cursor: pointer;
}
.lightbox-close:hover {
  color: var(--mainYellow);
}

.lightbox-control {
  position: absolute;
  font-size: 4rem;
  color: var(--mainOrange);
  transition: all 1s linear;
  cursor: pointer;
}
.lightbox-control:hover {
  color: var(--mainYellow);
}
.btnLeft {
  top: 50%;
  left: 0;
  transform: translateX(-60%);
}
.btnRight {
  top: 50%;
  right: 0;
  transform: translateX(60%);
}
              
            
!

JS

              
                (function(){
  const cartInfo = document.getElementById('cart-info');
  const cart = document.getElementById('cart');

  cartInfo.addEventListener('click', function(){
      cart.classList.toggle('show-cart');
  });
}());

(function(){
  const cartBtn = document.querySelectorAll('.store-item-icon');
  cartBtn.forEach(function(btn){
      btn.addEventListener('click', function(event){

          if(event.target.parentElement.classList.contains('store-item-icon')){
            let fullPath = event.target.parentElement.previousElementSibling.src;
            let pos = fullPath.indexOf('img') + 3;
            let partPath = fullPath.slice(pos);
            
            const item = {};
            item.img = `img-cart${partPath}`

            let name = event.target.parentElement.parentElement.nextElementSibling.children[0].children[0].textContent;

            let price = event.target.parentElement.parentElement.nextElementSibling.children[0].children[1].textContent;
            let finalPrice = price.slice(1).trim();
            item.name = name;
            item.price = finalPrice;
       

          const cartItem = document.createElement('div');
          cartItem.classList.add('cart-item','d-flex','justify-content-between','text-capitalize','my-3');

          cartItem.innerHTML =`
            <img src="${item.img}" class="img-fluid rounded-circle" id="item-img" alt="">
            <div class="item-text">

              <p id="cart-item-title" class="font-weight-bold mb-0">${item.name}</p>
              <span>$</span>
              <span id="cart-item-price" class="cart-item-price" class="mb-0">${item.price}</span>
            </div>
            <a href="#" id='cart-item-remove' class="cart-item-remove">
              <i class="fas fa-trash"></i>
            </a>
          </div>
         `;

      
          const cart = document.getElementById('cart');
          const total = document.querySelector('.cart-total-container');
          cart.insertBefore(cartItem, total);
          alert('Item added to the cart');
          showTotals();

          }
      });
  });


  function showTotals(){
      const total =[];
      const items = document.querySelectorAll('.cart-item-price')
      items.forEach(function(item){
          total.push(parseFloat(item.textContent));
      })
   
      const totalMoney = total.reduce(function(total, item){
          total +=item;
          return total
      }
      ,0)
      const finalMoney = totalMoney.toFixed(2);
      document.getElementById('cart-total').textContent = finalMoney;
      document.querySelector('.item-total').textContent = finalMoney;
      document.getElementById('item-count').textContent = total.length;
  }

  clear = document.getElementById('clear-cart')
  clear.addEventListener('click', function(){
      items = []
      document.getElementById('cart-total').textContent = 0;
      document.querySelector('.item-total').textContent = 0;
      document.getElementById('item-count').textContent = 0;
      cartItem.style.display = none;
  })
})();
              
            
!
999px

Console