Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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="container">
  <div class="brand x-brand">
    <h1>Our X brands</h1>
    <ul>
      <li><a href="#">Brand X01</a>
      <li><a href="#">Brand X02</a>
      <li><a href="#">Brand X03</a>
      <li><a href="#">Brand X04</a>
      <li><a href="#">Brand X05</a>
      <li><a href="#">Brand X06</a>
      <li><a href="#">Brand X07</a>
      <li><a href="#">Brand X08</a>
      <li><a href="#">Brand X09</a>
      <li><a href="#">Brand X10</a>
      <li><a href="#">Brand X12</a>
      <li><a href="#">Brand X13</a>
    </ul>
  </div>
  <div class="brand y-brand">
    <h1>Our Y brands</h1>
    <ul>
      <li><a href="#">Brand Y01</a>
      <li><a href="#">Brand Y02</a>
      <li><a href="#">Brand Y03</a>
      <li><a href="#">Brand Y04</a>
      <li><a href="#">Brand Y05</a>
      <li><a href="#">Brand Y06</a>
      <li><a href="#">Brand Y07</a>
      <li><a href="#">Brand Y08</a>
    </ul>
  </div>
  <div class="brand z-brand">
    <h1>Our Z brands</h1>
    <ul>
      <li><a href="#">Brand Z01</a>
      <li><a href="#">Brand Z02</a>
      <li><a href="#">Brand Z03</a>
      <li><a href="#">Brand Z04</a>
      <li><a href="#">Brand Z05</a>
      <li><a href="#">Brand Z06</a>
      <li><a href="#">Brand Z07</a>
      <li><a href="#">Brand Z08</a>
      <li><a href="#">Brand Z09</a>
      <li><a href="#">Brand Z10</a>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                @import compass

html
  height: 100%
body
  min-height: 100%
  color: #fff
  background: #7a7480 
  @include background-image(linear-gradient(top, #474150, #7a7480))
  background-repeat: no-repeat
  font-family: avenir, sans-serif
  font-size: 14px
ul,li
  margin: 0
  padding: 0
  list-style: none
.container
  position: relative
  max-width: 940px
  margin: 30px auto
  padding: 10px
  @include(single-box-shadow(0,1px,5px,rgba(0,0,0,0.5)))
  border: 1px solid #7a7480
  border-width: 0 1px 0 1px
  overflow: hidden
.brand
  position: relative
  height: 100px
  h1
    display: block
    float: left
    margin: 0 10px 0 0
    padding: 10px 10px 20px 0
    opacity: 0.3
    font-size: 14px
    font-weight: bold
    cursor: pointer
    -webkit-transition: opacity 300ms
    -moz-transition: opacity 300ms
    transition: opacity 300ms
    &:hover
      opacity: 1
  ul
    position: absolute
    left: 0
    top: 30px
    height: 60px
    z-index: 1
    overflow: hidden
    white-space: nowrap
  li
    display: inline-block
  a
    display: block
    margin: 5px 10px 0 0
    padding: 15px
    color: #fff
    text-decoration: none
    background: rgba(255,0,0,0.2)

.y-brand
  a
    background: rgba(0,255,0,0.2)
.z-brand
  a
    background: rgba(0,0,255,0.2)

.enhanced1
  height: 100px
  .brand
    height: auto
    ul
      top: 140px
    &.on,
    &.hover
      h1
        opacity: 1
      ul
        top: 40px
        z-index: 2
    &.on
      h1
        color: #fc0
    
      
/* loading */
.csstransitions .enhanced2
  ul
    top: 40px
  li
    max-width: 150px
    -webkit-transition: -webkit-transform 300ms,opacity 300ms
    -moz-transition: -moz-transform 300ms,opacity 300ms
    transition: transform 300ms,opacity 300ms
    &.fade1
      opacity: 0 !important
      -webkit-transition: -webkit-transform 500ms,opacity 500ms
      -moz-transition: -moz-transform 500ms,opacity 500ms
      transition: transform 500ms,opacity 500ms
      -webkit-transform: translate3d(0,60px,0) !important
      -moz-transform: translate3d(0,60px,0) !important
      transform: translate3d(0,60px,0) !important
    &.fade2
      -webkit-transition: max-width 500ms ease-out
      -moz-transition: max-width 500ms ease-out
      transition: max-width 500ms ease-out
      max-width: 0 !important
      overflow: hidden
  li,
  &.hover .brand.on li
    opacity: 0
    -webkit-transform: translate3d(0,100px,0)
    -moz-transform: translate3d(0,100px,0)
    transform: translate3d(0,100px,0)
  .on li,
  .hover li,
  &.hover .on.hover li
    opacity: 1
    -webkit-transform: translate3d(0,0,0)
    -moz-transform: translate3d(0,0,0)
    transform: translate3d(0,0,0)
  li:nth-child(2)
    -webkit-transition-delay: 20ms
    -moz-transition-delay: 20ms
    transition-delay: 20ms
  li:nth-child(3)
    -webkit-transition-delay: 40ms
    -moz-transition-delay: 40ms
    transition-delay: 40ms
  li:nth-child(4)
    -webkit-transition-delay: 60ms
    -moz-transition-delay: 60ms
    transition-delay: 60ms
  li:nth-child(5)
    -webkit-transition-delay: 80ms
    -moz-transition-delay: 80ms
    transition-delay: 80ms
  li:nth-child(6)
    -webkit-transition-delay: 100ms
    -moz-transition-delay: 100ms
    transition-delay: 100ms
  li:nth-child(7)
    -webkit-transition-delay: 120ms
    -moz-transition-delay: 120ms
    transition-delay: 120ms
  li:nth-child(8)
    -webkit-transition-delay: 140ms
    -moz-transition-delay: 140ms
    transition-delay: 140ms
  li:nth-child(9)
    -webkit-transition-delay: 160ms
    -moz-transition-delay: 160ms
    transition-delay: 160ms
  li:nth-child(10)
    -webkit-transition-delay: 180ms
    -moz-transition-delay: 180ms
    transition-delay: 180ms
  li:nth-child(11)
    -webkit-transition-delay: 200ms
    -moz-transition-delay: 200ms
    transition-delay: 200ms
  li:nth-child(12)
    -webkit-transition-delay: 220ms
    -moz-transition-delay: 220ms
    transition-delay: 220ms
  li:nth-child(13)
    -webkit-transition-delay: 240ms
    -moz-transition-delay: 240ms
    transition-delay: 240ms
  a
    -webkit-transition: -webkit-transform 300ms
    -moz-transition: -webkit-transform 300ms
    transition: -webkit-transform 300ms
    &:hover
      -webkit-transform: scale(1.2)
      -moz-transform: scale(1.2)
      transform: scale(1.2)
              
            
!

JS

              
                // .enhanced1 = javascript enabled, show/hide logo bars
// .enhanced2 = css transitions enabled, animations

var brandBar = (function() {
  
  var goNow = true;
  var IntervalObj = {};
  var waitDuration = 5000;
  var fade1Duration = 500;
  var fade2Duration = 1000;
  var cssTransitions = false;
  var goRounds = $('.brand ul');
  
  // init
  var init = function() { 
    // initial dom set-up
    $('.container').addClass('enhanced1');
    if (Modernizr.csstransitions) {
      $('.container').addClass('enhanced2');
      cssTransitions = true;
    }
    $('.brand').first().addClass('on');
    // set-up menu switching events
    brandSwitch();
    // set-up the logo carousels
    brandGoRoundInit();
    // recalc carousel necessity on resize
    $(window).resize(function() {
      brandGoRoundInit();
    })
  }
  
  // events to switch brand menus
  var brandSwitch = function() {
    $('.brand')
    .hover(
      function(ev){
        goNow = false;
        if ($('.container').hasClass('enhanced2')) {
          $('.container').addClass('hover')
          $(this).addClass('hover')
        }
      },function(ev) {
        goNow = true;
        $('.container').removeClass('hover')
        $(this).removeClass('hover')
      }
    )
    .click(function(ev){
      $('.brand').removeClass('on');
      $(this).addClass('on')
    })
  }
  
  // set up each brand menu by seeing if they need to carousel
  var brandGoRoundInit = function() {
    var maxWidth = $('.container').width();
    goRounds.each(function(i,el){
      var thisWidth = $(el).width();
      if (thisWidth > maxWidth - 12) {
        IntervalObj[i] = setInterval(function() {
          brandGoRoundLoop(i);
         },waitDuration);
      } else {
        clearTimeout(IntervalObj[i]);
      }
    })
  }
  
  // single carousel loop
  var brandGoRoundLoop = function(i) {
    var thisUl = goRounds.slice(i,i+1);
    // if mouseover menu, skip loop
    if (!goNow) 
      return
    // if this menu is not on, skip loop
    if (!thisUl.closest('.brand').hasClass('on'))
      return;
    var firstBrand = thisUl.find('li').first();
    if (cssTransitions) {
      firstBrand.addClass('fade1');
      setTimeout(function() {
        firstBrand.addClass('fade2');
        setTimeout(function() {
          lastBrand = firstBrand.clone().removeClass('fade1 fade2');
          firstBrand.remove();
          thisUl.append(lastBrand);
        },fade2Duration);
      },fade1Duration);
    };
  }
  
  // closure
  return {
    init: init
  }
  
})()

// go!
brandBar.init();
              
            
!
999px

Console