Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .mobile-container
  .header
    .nav
      .back.left
        i.fa.fa-long-arrow-left
      .cart.right
        i.fa.fa-shopping-cart
  .jumbo-tron
    h1.jumbo-tron-product-title CODE AND COFFEE MUG
    .image-close-up
    img#product-image(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/504262/Coffee%20Mug%20PSD%20Mockup.png" alt='Main Product')
  .product-details-wrapper
    .product-details
      .overview.product-description-section
        h3.product-description-section-title Overview
        p.pricing $15.00
        p The perfect way to inject yourself with sweet caffine. 
      .overview.product-description-section
        ul 
          h3.product-description-section-title Details
          li 100% grass fed ceramic.
          li Locally sourced ink.
          li Holds about 16oz of liquid.
          li For use only with hipster coffee that no one has heard of before.
  .footer
   .save.left Add To Wishlist 
     i.fa.fa-star
   button#add-to-cart.right Add to Cart
     
.pen-footer
  p @johngarcia9110 
    a.viewPens(href="https://codepen.io/johnbgarcia/" target='blank') view other pens

    
            
          
!
            
              *, *:before, *:after 
  box-sizing: border-box
  margin: 0
  padding: 0


html
  width: 100%
  height: 100%
  body
    width: 100%
    height: 100%
    margin: 0
    background: #42275a /* fallback for old browsers */
    background: -webkit-linear-gradient(to left, #42275a , #734b6d) /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(to left, #42275a , #734b6d) /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    font-family: 'Roboto', sans-serif
        

.mobile-container    
  position: absolute
  left: 50%
  top: 50%
  margin-left: -180px
  margin-top: -283.5px
  width: 360px 
  height: 567px
  border-radius: 5px
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.15)
  overflow: hidden
  .left
    float: left
  .right
    float: right
  .header
    width: 100%
    height: 50px
    background: #431d65
    border-bottom: 4px solid #b7b767
    .nav
      padding: 0 10px
      .fa
        color: white
        line-height: 50px
        cursor: pointer
      .cart
        font-size: 22px
      .back
        font-size: 20px
  .jumbo-tron
    width: 100%
    position: relative
    height: 250px
    overflow: hidden
    background: radial-gradient(center, #734b6d,  #42275a)
    .jumbo-tron-product-title
      position: absolute
      bottom: 10px
      left: 10px
      font-weight: bold
      color: white
      font-size: 24px
      text-shadow: 0px 0px 20px #431d65
    .image-close-up
      width: 600px
      height: 600px
      display: block
      opacity: 0.1
      transform: rotate(30deg) translateX(-118px)
    img
      max-width: 200px
      display: block
      position: absolute
      top: 50%
      left: 50%
      margin: -25% 0 0 -25%
.product-details-wrapper
  overflow: hidden
  width: 100%
  height: 207px
  position: relative
  margin: 0px auto
  .product-details
    background: #dcdcdc
    color: black
    font-family: 'Roboto', sans-serif
    -webkit-font-smoothing: antialiased
    padding: 5px
    width: 100%
    height: 100%
    overflow: auto
    display: block
    &::-webkit-scrollbar
      width: 0 !important
    .product-description-section
      background: white
      padding: 20px
      border-radius: 4px
      margin-bottom: 10px
      position: relative
      box-shadow: 0 2px 20px -16px black
      .pricing
        margin-bottom: 5px
        color: #dede7c
        position: absolute
        top: 10px
        right: 10px
        font-size: 20px
      ul
        
        li
          margin-left: 30px
        
    .product-description-section-title
      padding-bottom: 10px
.footer
  background: #613882
  width: 100%
  height: 60px
  display: block
  .save
    padding: 20px
    color: #fff
    cursor: pointer
  button
    margin: 10px
    padding: 10px 20px
    border-radius: 30px
    border: none
    background: #dede7c
    color: #613882
    font-family: 'Roboto', sans-serif
    font-weight: bold
    font-size: 16px
    cursor: pointer
    transition: .2s
    &:focus
      outline-width: 0
    &:active
      transform: translateY(4px)
    
.drop-to-cart
  animation: image-drop-to-cart 2s forwards
  
@keyframes image-drop-to-cart
  0%
    transform: translateY(0px)
  45%
    transform: translateY(400px)
    opacity: 1
  46%
    opacity: 0
  70%
    transform: translateY(-200px)
    opacity: 0
  100%
    transform: translateY(0px)
    opacity: 1
    
    
//PEN FOOTER
.pen-footer
  position: absolute
  bottom: 0
  right: 0
  padding: 10px
  color: #fff
  a
    text-decoration: none
    color: #431d65
    font-weight: bold
    background: #dede7c
    padding: 5px
    margin-left: 10px
            
          
!
            
              
var addToCartButton = document.getElementById('add-to-cart');
var productImage = document.getElementById('product-image');

addToCartButton.addEventListener('click', function(event){
    addClassToElement( productImage, 'drop-to-cart' );
    removeElementClassTimer( productImage, 'drop-to-cart', 2000 );
});

var addClassToElement = function( targetElement, classToAdd ){
  targetElement.classList.add(classToAdd);
}

var removeElementClassTimer = function( targetElement, classToRemove, delay ){
  setTimeout(function(){
    targetElement.classList.remove(classToRemove);
  }, delay);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console