cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>
  Flexbox demo: navigation with an unknown number of items
</h1>

<div class="nav">
  <ul>
    <li><a href="#">Products</a></li>
    <li><a href="#">Prices</a></li>    
    <li><a href="#">About us</a></li>      
    <li><a href="#">Contacts</a></li>
  </ul>
</div>

<p>Navigation items are <code>flex: auto</code>, so they share free space. The same thing happens when a crazy site administrator adds another item to the navigation:</p>

<div class="nav">
  <ul>
    <li><a href="#">Products</a></li>
    <li><a href="#">Prices</a></li>    
    <li><a href="#">About us</a></li> 
    <li><a href="#">Our beloved CEO</a></li> 
    <li><a href="#">Contacts</a></li>
  </ul>
</div>

<p>But we want that all items are the same width, so ...? We will change the model of flexibility by setting <code>flex-basis: 0</code> to absolute.</p>

<div class="nav nav-equal">
  <ul>
    <li><a href="#">Products</a></li>
    <li><a href="#">Prices</a></li>    
    <li><a href="#">About us</a></li> 
    <li><a href="#">Our beloved CEO</a></li> 
    <li><a href="#">Contacts</a></li>
  </ul>
</div>

<p class="css-mine">
  <small>
  (<a href="http://www.cssmine.com/css3-flexbox" target="_blank">CSS3 Flexbox</a> at CSS Mine)
  </small>
</p> 
            
          
!
            
              .nav {
  margin-bottom: 1em;
}

.nav ul {
  display: flex;
  list-style-type: none;
  margin: 0;
  padding: 0;  
}

.nav li {
  /* Tohle říká, že se položky spravedlivě dělí o volný prostor, ale vychází ze své původní šířky: */  
  flex: auto;
  margin: 0;
  padding: 0;
  background: rgba(0,0,0,.15);  
  border-left: 1px solid #EDE29F;
}

.nav ul > li:first-child {
  border-left: none;
}

.nav li a {
  display: block;
  padding: 1em;
  text-align: center;
  /* Pokud by měl obsah vylézt ven, vytečkujeme jej: */
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.nav-equal li {
  /* Model rozpočítávání volného místa změníme na absolutní, tzn. jakoby všechny položky měly ve výchozím stavu nulovou délku: */
  flex-basis: 0;
}

a {
  color: #5FA316;
}

.css-mine {
  position: fixed;
  bottom: 0;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console