cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div class="item">
  <h3 id="item_title">
    Fancy Item
  </h3>
  <p>
    A description about said fancy item.
  </p>
  <div class="item__actions">
    <button type="button"
            class="demo-btn"
            id="add_me" 
            aria-pressed="false" 
           aria-describedby="item_title">
      <span class="demo-btn__txt">
        Add to Cart
      </span>
      <span class="demo-btn__check">
        <svg fill="#fff" viewBox="0 0 100 100" aria-hidden="true"><g><path fill-rule="evenodd" clip-rule="evenodd" d="M39.363,79L16,55.49l11.347-11.419L39.694,56.49L72.983,23L84,34.085L39.363,79z"/></g></svg>
      </span>
    </button>
  </div>
</div>


<button type="submit">
  Check Out
</button>
            
          
!
            
              /*
  Shared button styles
*/
// Removes outline from submit buttons in Firefox
input[type="submit"]::-moz-focus-inner,
button[type="submit"]::-moz-focus-inner,
button:-moz-focusring,
input:-moz-focusring {
  outline: 0;
}


// Removes inner padding & border in Firefox 4+
button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

%btns {
  border: 0;
  font-size: inherit;
  font-weight: 500;
  letter-spacing: .02em;
  
  &:focus {
    outline-offset: 4px;
    outline: 3px solid #06aed5;
  }
}

/*
  Default Toggle Button Styles
*/
.demo-btn {
  @extend %btns;
  background: green;
  color: #fff;
  min-width: 200px;
  overflow: hidden;
  padding: 20px;
  position: relative;
  
  &:hover {
    background: darken(green, 5%);
  }
    
  // spans hold the button text and svg
  span {
    left: 0;
    position: absolute;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
    transition: text-indent .2s ease-in-out;
    width: 100%;
  }
  
  // checkmark svg sizing
  svg {
    height: 26px;
    width: 26px;
  }
}

/*
  Initial Text and checkmark positioning
*/
.demo-btn__txt {
  text-indent: 0%;
}

.demo-btn__check {
  text-indent: 200%;
}


/* 
  Styles for 'pressed' button state
*/
.demo-btn[aria-pressed="true"] {
  background: darkred;
  
  // update position of text
  .demo-btn__txt {
    text-indent: -20%;
  }
  
  // move checkmark into view
  .demo-btn__check {
    text-indent: 60%;
  }
}



/* other demo styling */
body {
  font-family: 'Helvetica', Arial, sans-serif;
  line-height: 1.35;
  padding: 20px;
}

.item {
  border: 1px solid;
  max-width: 400px;
  padding: 20px;

  h3 {
    margin: 0 0 .625em;
  }

  p {
    margin: 0 0 1.25em;;
  }
}


button[type="submit"] {
  @extend %btns;
  background: #faba4c;
  border: 2px solid;
  color: #000;
  margin-top: 1.25em;
  padding: .5em 1.25em;
  
  &:hover,
  &:focus {
    background: lighten(#faba4c, 5%);
  }
}
            
          
!
            
              var myBtn = document.getElementById('add_me');

myBtn.addEventListener('click', function ( e ) {
  /* toggle the pressed state of the button based on
     whatever the current value is */
  myBtn.setAttribute('aria-pressed', e.target.getAttribute('aria-pressed') === 'true' ? 'false' : 'true');
});
            
          
!
999px
Loading ..................

Console