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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <hr>
<div class="imgBox">
  <div class="imgs hidden"><img src="http://elevatorhose.com/mobile/images/EHF_Layout_r2_c1.jpg" alt=""></div>
  <div class="imgs hidden"><img src="http://elevatorhose.com/mobile/images/EHF_Layout_r2_c1.jpg" alt=""></div>
  <div class="imgs hidden"><img src="http://elevatorhose.com/mobile/images/EHF_Layout_r2_c1.jpg" alt=""></div>
  <div class="imgs hidden"><img src="http://elevatorhose.com/mobile/images/EHF_Layout_r2_c1.jpg" alt=""></div>
</div>
<hr>
              
            
!

CSS

              
                .imgBox
{
  width: 100%;
  background-color: gray;
  height: 0px;
}
.imgs
{
  width: 100%;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.hidden
{
  display: none;
}
              
            
!

JS

              
                # get image containers
imgBox = document.querySelectorAll '.imgBox' .0
imgItem = [...document.querySelectorAll '.imgs']
# define current image state storage
imgState = {
  index: -1
  tween: null
}


# define tween method
imgDisplay = (index) !->
  # check if we need to change current
  if index == imgState.index
    return
  # change
  imgState.index = index
  # stop previous timeline
  if imgState.tween
    imgState.tween.kill!
  # create timeline
  imgState.tween = t = new TimelineLite!
  # hide all first
  t.to imgItem, 0.2, {opacity: 0}
  t.set imgItem, {display: 'none'}
  # enable current
  t.set imgItem[index], {display:'flex'}
  # run after
  t.add !->
    # determine height of the image
    h = imgItem[index].clientHeight
    # show image and resize box
    t.addLabel 'L1'
    t.to imgItem[index], 0.2, {
      opacity: 1
      ease: Power2.easeIn
    }, 'L1'
    t.to imgBox, 0.2, {
      height: h
      ease: Power2.easeOut
    }, 'L1'


# define resize function
windowResize = !->
  # get width
  w = window.innerWidth
  # determine which image to show
  if w > 1200
    index = 0
  else if w > 800
    index = 1
  else if w > 600
    index = 2
  else
    index = 3
  # show it
  imgDisplay index


# add event handler
window.addEventListener 'resize', windowResize
# initialize
windowResize!

              
            
!
999px

Console