Tuesday 21 October 2014

Hidden Flyout Shopping Cart Menu with CSS3

HTML:-


<div id="wrapper">
  <div class="cart-tab visible">  
    <a href="#" title="View your shopping cart" class="cart-link">
      <span class="amount">$22.00</span>
      <span class="contents">2 items</span>
    </a>
    <div class="cart">
      <h2>Cart</h2>
      <div class="cart-items">
        <ul>
          <li class="clearfix">
            <img src="img/dark-clean-hoodie.jpg" class="productimg">
            <h4>Dark Hoodie</h4>
            <span class="item-price">$11.00</span>
            <span class="quantity">Quantity: 1</span>
          </li>
 
          <li class="clearfix">
            <img src="img/spongebob-nike-shoes.jpg" class="productimg">
            <h4>SpongeBob Shoes</h4>
            <span class="item-price">$11.00</span>
            <span class="quantity">Quantity: 1</span>
          </li>
        </ul>
      </div><!-- @end .cart-items -->
 
      <a href="#" class="checkout">Go To Checkout →</a>
    </div><!-- @end .cart -->
  </div><!-- @end .cart-tab -->


CSS:-

/** page structure **/
#wrapper {
  display: block;
  width: 850px;
  background: #fff;
  margin: 0 auto;
  margin-bottom: 35px;
  padding: 25px 30px;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -webkit-box-shadow: 0 1px 1px rgba(205,205,205,0.55);
}
 
 
#productlist {
  display: block;
  margin-bottom: 15px;
}
 
#productlist li {
  display: block;
  float: left;
  margin-bottom: 35px;
}
 
#productlist li img {
  display: block;
  float: left;
  margin-right: 10px;
}
#productlist li .details {
  display: block;
  float: left;
  width: 180px;
}




/** flyout menu **/
.cart-tab { 
  width: 22em;
  position: fixed;
  top: 5em;
  z-index: 9999;
  background: #fff;
  right: -22em;
  -webkit-transition: right ease .5s;
  -moz-transition: right ease .5s;
  -o-transition: right ease .5s;
  transition: right ease .5s;
}
 
.cart-tab a.cart-link {
  position: absolute;
  top: 0;
  left: -9em;
  width: 8.6em;
  display: block;
  background: #fff;
  padding: 1.8em;
  text-decoration: none;
  -webkit-transition: left ease .5s;
  -moz-transition: left ease .5s;
  -o-transition: left ease .5s;
  transition: left ease .5s;
  -webkit-border-top-left-radius: 3px;
  -webkit-border-bottom-left-radius: 3px;
  -moz-border-radius-topleft: 3px;
  -moz-border-radius-bottomleft: 3px;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}
.cart-tab a.cart-link:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  right: -10px;
  width: 10px;
  height: 100%;
  background: #fff;
}
 
.cart-tab:hover { right: 0; }



.cart-tab a.cart-link .amount { 
  display: block; 
  color: #515151; 
  font-size: 1.5em; 
  line-height: 1.7em; 
  font-weight: bold; 
  margin-bottom: 8px;
}
.cart-tab a.cart-link .contents { 
  display: block;
  color: #666;
  font-size: 1em;
}
 
.cart-items { display: block; margin-bottom: 25px; }
.cart-items ul { display: block; list-style: none; }
.cart-items ul li { display: block; margin-bottom: 8px; padding-bottom: 10px; cursor: pointer; border-bottom: 1px dotted #888; }

.cart-items ul li .item-price, .cart-items ul li .quantity { display: block; margin-bottom: 2px; font-size: 1.1em; }
.productimg { display: block; float: left; margin-right: 8px; }
 
.cart-tab .cart { padding: 1.5em; margin: 0; }
.cart-tab .cart .checkout {
  font-size: 1.2em;
  padding: 4px 11px;
  border: 1px solid #467fc5;
  color: #467fc5;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
}
.cart-tab .cart .checkout:hover { background: #467fc5; color: #fff; }

.cart-tab a.cart-link,.cart-tab .cart {
  -webkit-box-shadow: 0 2px 10px 0 rgba(0,0,0,0.2);
  -moz-box-shadow: 0 2px 10px 0 rgba(0,0,0,0.2);
  -o-box-shadow: 0 2px 10px 0 rgba(0,0,0,0.2);
  box-shadow: 0 2px 10px 0 rgba(0,0,0,0.2);
}
 
.cart-tab .cart {
  -webkit-border-bottom-left-radius: 3px;
  -webkit-border-bottom-right-radius: 3px;
  -moz-border-radius-bottomleft: 3px;
  -moz-border-radius-bottomright: 3px;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
}

No comments:

Post a Comment