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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <aside class="cart-menu">
 
<a id="cart-button" class="button" href="http://yoursite.com/cart/" style="opacity: 1;">
  <span>Cart</span>
  <b>(3)</b>
</a>


<div class="cart-dialog"> <div class="widget woocommerce widget_shopping_cart">
  <h2 class="widgettitle">Cart</h2>
  <div class="widget_shopping_cart_content" style="opacity: 1;">

  <ul class="woocommerce-mini-cart cart_list product_list_widget ">
    <li class="woocommerce-mini-cart-item mini_cart_item">
      <a href="#" class="remove remove_from_cart_button">×</a>
      <a href="http://example.com/product/macbook-air-2020/">
        <img width="300" height="300" src="https://picsum.photos/id/0/150/150" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
        Macbook Air 2020
      </a>
      <span class="quantity">
        1 ×
        <span class="woocommerce-Price-amount amount">
          <span class="woocommerce-Price-currencySymbol">£</span>700.00
        </span>
      </span>
    </li>
    <li class="woocommerce-mini-cart-item mini_cart_item">
      <a href="#" class="remove remove_from_cart_button">×</a>
      <a href="http://example.com/product/nikon-x123/">
        <img width="300" height="300" src="https://picsum.photos/id/250/150/150" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
        Nikon X123
      </a>
      <span class="quantity">
        1 ×
        <span class="woocommerce-Price-amount amount">
          <span class="woocommerce-Price-currencySymbol">£</span>400.00
        </span>
      </span>
    </li>
    <li class="woocommerce-mini-cart-item mini_cart_item">
      <a href="#" class="remove remove_from_cart_button">×</a>
      <a href="http://example.com/product/timex-alarm/">
        <img width="300" height="300" src="https://picsum.photos/id/357/150/150" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail">
        Timex Alarm Clock
      </a>
      <span class="quantity">
        1 ×
        <span class="woocommerce-Price-amount amount">
          <span class="woocommerce-Price-currencySymbol">£</span>150.00
        </span>
      </span>
    </li>
  </ul>

  <p class="woocommerce-mini-cart__total total">
    <strong>Subtotal:</strong>
    <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1250.00</span>
  </p>


  <p class="woocommerce-mini-cart__buttons buttons">
    <a href="http://lab.test/wptips/cart/" class="button wc-forward">View cart</a>
    <a href="http://lab.test/wptips/checkout/" class="button checkout wc-forward">Checkout</a>
  </p>

  </div>
</div> </div>

</aside>
              
            
!

CSS

              
                .cart-menu
  position: fixed
  z-index: 1000
  bottom: 1rem
  right: 1rem
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"

  > .button
    padding: 0.5rem 1rem
    background-color: #333
    color: white
    border-radius: 4px
    
  a
    text-decoration: none

 
.cart-dialog
  visibility: hidden
  opacity: 0
  transform: translateY(10px)
  transition: all .25s ease-in-out
  
  overflow-y: auto
  position: absolute
  bottom: calc(100% + 1rem)
  right: 0
  width: 320px
  max-height: 480px
  background-color: white
  box-shadow: 0 0 10px rgba(0,0,0, .2)
  
  &.cart-dialog--active
    visibility: visible
    opacity: 1
    transform: none

  .widgettitle
    display: none

  .widget
    margin-bottom: 0

  .widget img
    display: inline-block
    width: 70px
    height: 70px
    border-radius: 4px


.widget_shopping_cart_content
  display: grid
  grid-template-columns: 1fr 1fr


ul.product_list_widget
  grid-column: span 2
  margin: 0
  padding: 0.5rem 1rem
  list-style-type: none
  
  img
    float: right
    
  a
    display: block

  li.mini_cart_item
    position: relative
    margin-bottom: 1rem
    font-size: 18px
    line-height: 1.25
  
  // clearfix floating image
  li.mini_cart_item::before,
  li.mini_cart_item::after
    content: " "
    display: table
  li.mini_cart_item::after
    clear: both

  a.remove_from_cart_button
    display: flex
    align-items: center
    justify-content: center
    
    position: absolute
    z-index: 10
    top: 0
    right: 0
    margin: 0
    width: 24px
    height: 24px
    line-height: 24px
    background-color: red
    color: white
    font-weight: 700
    transform: translateX(50%) translateY(-4px)
    border-radius: 50%

  p
    margin: 0.5rem 0

  span.quantity
    display: inline-block
    margin-top: 4px
    font-size: 14px

// subtotal
.woocommerce-mini-cart__total
  display: flex
  flex-direction: column
  margin: 0
  padding: 0.5rem 0.25rem
  padding-left: 1rem
  background-color: rgba(black, .1)
  line-height: 1

  strong
    display: block
    font-size: 14px

// checkout button
p.woocommerce-mini-cart__buttons
  display: flex
  align-items: center
  justify-content: stretch
  
  margin: 0
  padding: 0.5rem 0.25rem
  padding-right: 1rem
  background-color: rgba(black, .1)
  line-height: 1

  .button
    width: 100%
    padding: 0.5rem 1rem
    margin: 0
    color: white
    text-align: center
    font-weight: 700
    text-transform: uppercase
    letter-spacing: 0.05em
    border-radius: 4px

  .button:not(.checkout)
    display: none
  .button.checkout
    background-color: #0073aa
              
            
!

JS

              
                (function( $ ) {
  'use strict';

  document.addEventListener('DOMContentLoaded', onReady);
  function onReady() {
    $( '#cart-button' ).on( 'click', toggleCart );
    $( '.cart-dialog' ).on( 'click', preventCloseCart );
    $( document ).on( 'click', closeCart );
  }
  
  function toggleCart( e ) {
    e.stopPropagation();
    $( '.cart-dialog' ).toggleClass( 'cart-dialog--active' );
  }
  
  function preventCloseCart( e ) {
    e.stopPropagation();
  }
 
  function closeCart( e ) {
    $( '.cart-dialog--active' ).removeClass( 'cart-dialog--active' );
  }
     
})( jQuery );
              
            
!
999px

Console