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

Quick-add: + add another resource

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.

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

Console