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 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


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.


                <nav class='greedy'>
  <ul class='links'>
    <li><a href='#'>navbar</a></li>
    <li><a href='#'>that</a></li>
    <li><a href='#'>handles</a></li>
    <li><a href='#'>overflowing</a></li>
    <li><a href='#'>menu</a></li>
    <li><a href='#'>elements</a></li>
    <li><a href='#'>effortlessly</a></li>
  <ul class='hidden-links hidden'></ul>
<p>This project is on <a target="_blank" href="">github</a></p>
<h5>Resize the window and any overflowing items will get stacked into the dropdown menu</h5>


                nav.greedy {
  position: relative;
  height: 60px;
  display: flex;
  align-items: center;
  background: #f2f2f2;

nav.greedy h1 {
  display: flex;
  align-self: stretch;
  align-items: center;
  background: #d8d8d8;
  color: #404040;
  padding: 0 1.5rem;
  font-weight: bold;

nav.greedy button {
  align-self: stretch;
  transition: all .4s ease-out;
  padding: 0 1rem 0 1.5rem;
  outline: 0;
  border: 0;
  font-size: 0.9rem;
  font-weight: bold;
  background: #c8c8c8;
  color: #404040;

nav.greedy button.hidden {
  transition: none;
  border-right: 0.5rem solid #b6b6b6;
  width: 0;
  padding: 0;
  overflow: hidden;

nav.greedy button::after {
  content: attr(count);
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  background: #9f9f9f;
  color: #f2f2f2;
  box-shadow: 0 0 1px 0 rgba(0,0,0,0.8);
  border-radius: 50%;
  font-size: 14px;
  line-height: 14px;
  margin-left: 1rem;
  margin-right: calc(-1rem + -8px);

ul.links {
  display: flex;
  justify-content: flex-end;
  flex: 1;
  overflow: hidden;

ul.links li {
  flex: none;
  padding: 1rem;

ul.links li a {
  color: #404040;

ul.hidden-links {
  position: absolute;
  background: #d8d8d8;
  right: 0;
  top: 100%;

ul.hidden-links li a {
  color: #404040;
  padding-right: 1rem;

ul.hidden-links.hidden {
  display: none;

ul.hidden-links li {
  padding: 1rem;

-- Demo Styles

* {
  box-sizing: border-box;

html {
  background: #fefefe;

body {
  padding: 2rem;

h5 {
  text-align: center;
  margin: auto;
  font-size: 0.8rem;
  line-height: 140%;
  margin-top: 1rem;
  max-width: 50ex;

p {
  text-align: center;
  margin-top: 3rem;

html {
  width: 100%;
  height: 100%;
  font-family: Helvetica, sans-serif;


                $(function() {

  var $nav = $('nav.greedy');
  var $btn = $('nav.greedy button');
  var $vlinks = $('nav.greedy .links');
  var $hlinks = $('nav.greedy .hidden-links');

  var numOfItems = 0;
  var totalSpace = 0;
  var breakWidths = [];

  // Get initial state
  $vlinks.children().outerWidth(function(i, w) {
    totalSpace += w;
    numOfItems += 1;

  var availableSpace, numOfVisibleItems, requiredSpace;

  function check() {

    // Get instant state
    availableSpace = $vlinks.width() - 10;
    numOfVisibleItems = $vlinks.children().length;
    requiredSpace = breakWidths[numOfVisibleItems - 1];

    // There is not enought space
    if (requiredSpace > availableSpace) {
      numOfVisibleItems -= 1;
      // There is more than enough space
    } else if (availableSpace > breakWidths[numOfVisibleItems]) {
      numOfVisibleItems += 1;
    // Update the button accordingly
    $btn.attr("count", numOfItems - numOfVisibleItems);
    if (numOfVisibleItems === numOfItems) {
    } else $btn.removeClass('hidden');

  // Window listeners
  $(window).resize(function() {

  $btn.on('click', function() {