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

Auto Save

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="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Jyn up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Jyn down">⬇</button>
    </div>
    <h2 class="listing__title">Jyn Erso</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Rey up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Rey down">⬇</button>
    </div>
    <h2 class="listing__title">Rey</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Leia up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Leia down">⬇</button>
    </div>
    <h2 class="listing__title">Princess Leia Organa</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Mon Mothma up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Mon Mothma down">⬇</button>
    </div>
    <h2 class="listing__title">Mon Mothma</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Ashoka up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Ashoka Down">⬇</button>
    </div>
    <h2 class="listing__title">Ahsoka Tano</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Maz up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Maz down">⬇</button>
    </div>
    <h2 class="listing__title">Maz Kanata</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Padme up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Padme down">⬇</button>
    </div>
    <h2 class="listing__title">Queen Padmé Amidala</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Phasma up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Phasma down">⬇</button>
    </div>
    <h2 class="listing__title">Captain Phasma</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Rose up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Rose down">⬇</button>
    </div>
    <h2 class="listing__title">Rose Tico</h2>
  </div>

  <div class="listing">
    <div class="listing__tabs">
      <button class="listing__tab listing__tab--top" data-dir="up" aria-label="Move Holdo up">⬆</button>
      <button class="listing__tab listing__tab--bottom" data-dir="down" aria-label="Move Holdo down">⬇</button>
    </div>
    <h2 class="listing__title">Vice Admiral Amilyn Holdo</h2>
  </div>
</div>
              
            
!

CSS

              
                /// Settings
$c-primary: #560D55;
$c-border: $c-primary;
$c-tab: darken(#560D55, 12%);
$c-text: #F9F4EE;
$c-accent: #F87E44;
$c-background: #ADC8C0;

$font--primary: 'Cairo', 'Helvetica Neue', 'Helvetica', Arial, serif;

/// Body Things

body {
  background-color:$c-background;
  font-family: $font--primary;
  color: $c-text;
}

button {
  border: none;
  font-size: 120%;
}

/// Pen Styles

.listing {
  background-color: $c-primary;
  border-radius: 0.5rem;
  min-height: 5rem;
  
  margin: 1rem 0.75rem;

  letter-spacing: 1px;
  
  -webkit-font-smoothing: antialiased;
  
  display: flex;
  
  &__tabs {
    max-width: 3rem;
    padding: 0;
    // background-color: $c-tab;
    border-radius: 0.5rem 0 0 0.5rem;
    display: inline;
    text-align: center;
    
    display: flex;
    flex-direction: column;
  }
  
  &__tab {
    color: $c-accent;
    background-color: $c-tab;
    padding: 0.5rem;
    margin: 0;
    height: 50%;
    width: 3rem;

    &:hover {
      background-color: invert($c-tab);
      color: black;
      cursor: pointer;
    }
    
    &--top {
      border-radius: 0.5rem 0 0 0;
    }
    &--bottom {
      border-radius: 0 0 0 0.5rem;
    }
  }
  
  &__title {
    padding-left: 0.75rem;
    display: inline;
  }
}
              
            
!

JS

              
                // Cool selector thing my friend Adam uses
const $$ = (s, context) => {
  const scope = context || document;
  return [...scope.querySelectorAll(s)];
};

// Use that selector thing
const tabs = $$('.listing__tab');

// Vanilla JS doesn't include insertAfter, so let's make it up
const insertAfter = (newNode, referenceNode) => {
  referenceNode.parentNode.insertBefore(newNode, referenceNode.nextElementSibling);
};

// Here's our move function
const moveListing = (e) => {
  // Find the event target for callback reasons
  const el = e.target;
  // This makes sure we move the whole "listing" element
  const parentListItem = el.parentNode.parentNode;
  // Which way? 
  const dir = el.getAttribute('data-dir');
  
  if (dir === 'up') {
    // If UP, we use vanilla JS's "insertBefore"
    parentListItem.parentNode.insertBefore(parentListItem, parentListItem.previousElementSibling);
    
  } else if (dir === 'down') {
    // if DOWN, we use our fake jQuery
    insertAfter(parentListItem, parentListItem.nextElementSibling);
  }
};


// Time to call the move function! 
// If an array of buttons exists
if (tabs && tabs.length) {
  // loop over the buttons
  tabs.forEach((tab) => {
    // if the button exists
    if (tab) {
      // and it is clicked, call the move function.
      tab.addEventListener('click', moveListing);
    }
  });
}

              
            
!
999px

Console