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

              
                <div class="wrapper">
  
  <div class="intro">
    <h1>Animated CSS3 USB Drives</h1>
  </div>
  
  <div class="drives">
    
    <!-- Blue USB Drive -->
    <a class="usb-drive" href="#" title="Download">
      <div class="casing">Download</div>
      <div class="connector">
        <div class="inner">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </div>
      </div>
      <div class="cap">
        <i class="fa fa-cloud-download"></i>
      </div>
    </a>
    
    <!-- Purple USB Drive -->
    <a class="usb-drive purple" href="#" title="Download">
      <div class="casing">Download</div>
      <div class="connector">
        <div class="inner">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </div>
      </div>
      <div class="cap">
        <i class="fa fa-download"></i>
      </div>
    </a>
    
    <!-- Red USB Drive -->
    <a class="usb-drive red" href="#" title="Share">
      <div class="casing">Share</div>
      <div class="connector">
        <div class="inner">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </div>
      </div>
      <div class="cap">
        <i class="fa fa-share"></i>
      </div>
    </a>
    
    <!-- Orange USB Drive -->
    <a class="usb-drive orange" href="#" title="Upload">
      <div class="casing">Upload</div>
      <div class="connector">
        <div class="inner">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </div>
      </div>
      <div class="cap">
        <i class="fa fa-cloud-upload"></i>
      </div>
    </a>
    
    <!-- Green USB Drive -->
    <a class="usb-drive green" href="#" title="Download">
      <div class="casing">Upload</div>
      <div class="connector">
        <div class="inner">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </div>
      </div>
      <div class="cap">
        <i class="fa fa-upload"></i>
      </div>
      
      <!-- Carbon Pattern USB Drive -->
      <a class="usb-drive carbon" href="#" title="Stash">
        <div class="casing">Stash</div>
        <div class="connector">
          <div class="inner">
            <span aria-hidden="true"></span>
            <span aria-hidden="true"></span>
          </div>
        </div>
        <div class="cap">
          <i class="fa fa-star"></i>
        </div>
      </a>
    </div>
    
    <div class="outro">
      <p>CSS experiment to make buttons that look like USB drives. <br />The goal was to make them without using images, purely HTML &amp; CSS.</p>
      <p><strong>Hover and click to see them in action.</strong></p>
      <p>The final carbon example uses a <a href="http://lea.verou.me/css3patterns/" title="CSS3 patterns">CSS3 pattern</a>.</p>
      <p>Standalone code can be found on <a href="https://github.com/johnslipper/animated-usb-drive-styled-links" title="View code on GitHub" target="_blank">GitHub</a></p>
    </div>
    
  </div><!-- /wrapper -->
              
            
!

CSS

              
                /* Variables
------------ */
@gray: #555;
@grayLight: #999;
@grayDark: #333;
@orange: #f89406;
@purple: #7a43b6;
@yellow: #ffc40d;
@green: #46a546;
@red: #a22218;


/* Layout styles
---------------- */
.wrapper {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  width: 740px;
  margin: 40px auto;
  text-align: center;
}

.intro {
  margin-bottom: 20px;
}

.outro {
  margin-top: 40px;
}

.drives {
  .clearfix();
}


/* USB drive base styles
------------------------ */

.usb-drive {
  display: block;
  float: left;
  width: 246px; /* Open size plus casing margin */
  margin: 25px auto;
  text-align: left;
  cursor: pointer;
  .usb-drive-color();
  .clearfix();
  user-select: none; /* Stop text from being highlighted */
  font-smoothing: antialiased;
  & > div {
    float: left;
    height: 50px;
  }
  .casing, .cap {
    line-height: 50px;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.65), 0 1px 1px rgba(255, 255, 255, 0.35);
  }
  .casing {
    width: 95px;
    margin-left: 36px; /* Offset by width of connector for centering */
    padding-left: 15px;
    padding-right: 10px;
    border-radius: 25px 0 0 25px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
  }
  .connector {
    width: 0;
    position: relative;
    overflow: hidden;
    transition: width 100ms ease-in-out;
    .inner {
      margin-top: 12px;
      width: 30px;
      height: 30px;
      border-radius:0 2px 2px 0;
      #gradient > .vertical-three-colors(@grayLight, lighten(@grayLight, 15%), 90%, lighten(@gray, 10%));
      box-shadow: inset 3px 0 3px rgba(0,0,0,0.15), 0 5px 0 darken(@gray, 10%), inset 0 2px 1px rgba(255, 255, 255, 0.45), 0 5px 10px rgba(0, 0, 0, 0.65);
      span {
        position: absolute;
        width: 5px;
        height: 5px;
        left: 7px;
        background-color: @grayDark;
        border-radius: 1px;
        box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.35);
        &:first-of-type {
          top: 19px;
        }
        &:last-of-type {
          top: 29px;
        }
      }
    }
 }
  
	.cap {
    width: 36px;
    padding-left: 10px;
    border-radius: 0 25px 25px 0;
    font-size: 18px;
  }
  /* active state */
  &:active, &.active {
    text-decoration: none;
    .casing, .cap {
      color: #FFF;
    }
  }
  /* hover state */
  &:hover, &.hover {
    .connector {
      width: 35px;
    }
  }
}


/* USB Drive Colouring
---------------------- */
.usb-drive-color(@driveColor: #04aef4) {
  .casing, .cap {
    color: darken(@driveColor, 15%);
    background-color: @driveColor;
    border-top: 1px solid @driveColor;
    border-bottom: 1px solid lighten(@driveColor, 5%);
    box-shadow: 0 5px 0 darken(@driveColor, 20%), inset 0 2px 1px rgba(255, 255, 255, 0.35), 0 8px 3px rgba(0, 0, 0, 0.35);
    #gradient > .vertical(lighten(@driveColor, 10%), darken(@driveColor, 8%));
  }
}

.red {
  .usb-drive-color(lighten(@red, 5%));
}

.orange {
  .usb-drive-color(saturate(@orange, 5%));
}

.purple {
  .usb-drive-color(saturate(@purple, 5%));
}

.green {
  .usb-drive-color(saturate(@green, 5%));
}

/* Carbon example pattern from
   http://lea.verou.me/css3patterns/
------------------------------------ */
.carbon .casing,
.carbon .cap {
  color: #CCC;
  background: linear-gradient(27deg, #222222 5px, transparent 5px) 0 5px, linear-gradient(207deg, #222222 5px, transparent 5px) 10px 0px, linear-gradient(27deg, #2f2f2f 5px, transparent 5px) 0px 10px, linear-gradient(207deg, #2f2f2f 5px, transparent 5px) 10px 5px, linear-gradient(90deg, #282828 10px, transparent 10px), linear-gradient(#2a2a2a 25%, #1a1a1a 25%, #272727 50%, transparent 50%, transparent 75%, #313131 75%, #313131);
  background-color: #202020;
  -webkit-background-size: 20px 20px;
  -moz-background-size: 20px 20px;
  -o-background-size: 20px 20px;
  background-size: 20px 20px;
  -webkit-box-shadow: 0 5px 0  #000000 , inset 0 2px 1px rgba(255, 255, 255, 0.35), 0 8px 3px rgba(0, 0, 0, 0.35);
  -moz-box-shadow: 0 5px 0  #000000 , inset 0 2px 1px rgba(255, 255, 255, 0.35), 0 8px 3px rgba(0, 0, 0, 0.35);
  box-shadow: 0 5px 0  #000000 , inset 0 2px 1px rgba(255, 255, 255, 0.35), 0 8px 3px rgba(0, 0, 0, 0.35);
  border-top: 1px solid #333333;
  border-bottom: 1px solid #404040;
}

.carbon .cap {
  color: #ffc40d;
}


/* Font Awesome styles
---------------------- */
@import url("//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css");



/* Utility Mixins (Twitter Bootstrap 2.3)
----------------------------------------- */
#gradient {
  .vertical(@startColor: #555, @endColor: #333) {
    background-color: mix(@startColor, @endColor, 60%);
    background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
    background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
    background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
    background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
    background-repeat: repeat-x;
  }
  .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
    background-color: mix(@midColor, @endColor, 80%);
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
    background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor);
    background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor);
    background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor);
    background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor);
    background-repeat: no-repeat;
  }
}

.clearfix {
  &:before,
  &:after {
    display: table;
    content: "";
    line-height: 0;
  }
  &:after {
    clear: both;
  }
}

/* Responsive Tweaks
-------------------- */
@media (min-width: 492px) and (max-width: 739px) {
  
  .wrapper {
    width: 492px;
  }
  
}

@media (max-width: 491px) {
  
  .wrapper {
    width: auto;
    margin: auto;
  }
  
  .usb-drive {
    float: none;
  }
  
}
              
            
!

JS

              
                
              
            
!
999px

Console