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.

+ add another resource


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


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.


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.



  <link href=',300,700' rel='stylesheet' type='text/css'>

  <div class="content">
    <div class="wrapper">
      <div class="box box1">
        <h1 id="box1">box 1</h1>
      <div class="box box2">
        <h1>box 2</h1>
      <div class="box box3">
        <h1>box 3</h1>
  <div class="directions">Scroll the boxes left and right.</div>



  margin: 0;
  padding: 0;
  box-sizing: border-box;

  height: 100%;
  color: #fff;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 12px;

.directions {
  color: #000;
  font-size: 24px;

  position: relative;
  overflow: scroll;
  width: 100%;

.wrapper { 
  width: 2700px;

  width: 900px;
  height: 100px;
  float: left;
  position: relative;

.box h1{
  padding: 0;
  position: absolute;
  transform: translate3d(0,0,0);

  background-color: #9b59b6;

  background-color: #1abc9c;

  background-color: #e74c3c;


                $h1s = $('h1')
$container = $('.content')
oldLeft = -1

# Array of objects to be "sticky" headers
headers = []
activeHeader = {}
oldHeader = {}

scroll = window.requestAnimationFrame

# Cache values and jQuery selectors
for header in $h1s
  leftBorder = $(header).parent().position().left
  rightBorder = $(header).parent().position().left + $(header).parent().width() - $(header).width()
  headers.push {
    leftBorder: leftBorder 
    rightBorder: rightBorder
    $element: $(header)

getActiveHeader = (offset) ->
  for header in headers
    if header.rightBorder >= offset and header.leftBorder <= offset
      return activeHeader = header
      activeHeader = {}

getOffset = (offset) ->
  return (offset - activeHeader.leftBorder) >>> 0
resetHeader = (offset) ->
  if oldHeader.$element and offset < oldHeader.leftBorder
    oldHeader.$element.css("transform", "translate3d(0px, 0px, 0px)")
animate = ->
  newLeft = $container.scrollLeft()
  console.log newLeft
  if newLeft is oldLeft
    scroll animate
    return false
    oldLeft = newLeft
  if not _.isEqual oldHeader, activeHeader
  if activeHeader.$element
    activeHeader.$element.css("transform", "translate3d(#{getOffset(newLeft)}px, 0, 0)")
  oldLeft = newLeft
  oldHeader = activeHeader
  scroll animate