Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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.

HTML

              
                <h1>Dynamic width using the magic of <strong><i>flex-shrink</i></strong></h1>

<div class="table">
  <div class="row row--last">
    <div class="col asset-1">
      I wanna have this text longer because it is <strong>more important</strong>
    </div>
    <div class="col col--last asset-2">
      This text must be also shown even though it is not as important
    </div>
  </div>
</div>

<div class="table">
  <div class="row row--last">
    <div class="col asset-1">
      I wanna have this text longer because it is <strong>more important</strong> really really important .
    </div>
    <div class="col col--last asset-2">
      This text must be also shown even though it is not as important
    </div>
  </div>
</div>

<div class="table">
  <div class="row row--last">
    <div class="col asset-1">
      I wanna have this text longer because it is <strong>more important</strong> really really really really really important .
    </div>
    <div class="col col--last asset-2">
      This text must be also shown even though it is not as important
    </div>
  </div>
</div>

<div class="table">
  <div class="row row--last">
    <div class="col asset-1">
      Sometimes the text here is short 
    </div>
    <div class="col col--last asset-2">
      Let's show then the full text  due to it has enough room now, it grows dynamically
    </div>
  </div>
</div>

<h3 class="u-separator u-align-left">
In the table below the most important datas would be the name and the skills so if you don't want to break the lines let's appy <strong>flex-shrink</strong> in those less relevant datas (id and jobbies)
</h3>

<div class="table">
  <div class="row">
    <div class="col name">
      George Washington
    </div>
    <div class="col age">
      56
    </div>
    <div class="col address">
      Virginia
    </div>
    <div class="col number-id">
      898900980890E
    </div>
    <div class="col jobbies">
      Swing, Coding, Play guitar, Sing, TV, Blogging..
    </div>
    <div class="col col--last skills">
      Javascript, Ruby and Python
    </div>
  </div>
  
   <div class="row">
    <div class="col name">
      John Adams
    </div>
    <div class="col age">
      43
    </div>
    <div class="col address">
      Massachusetts
    </div>
    <div class="col number-id">
      898900980890E
    </div>
    <div class="col jobbies">
      Swing, Coding, Play guitar, Sing, TV, Blogging..
    </div>
    <div class="col col--last skills">
      JS, Ruby, Python, HTML5, Node, React, Angular.
    </div>
  </div>
  
  <div class="row row--last">
    <div class="col name">
      Thomas Jefferson
    </div>
    <div class="col age">
      Unknown
    </div>
    <div class="col state">
      Virginia
    </div>
    <div class="col number-id">
      898900980890E
    </div>
    <div class="col jobbies">
      Swing, Coding, Play guitar, Sing, TV, Blogging..
    </div>
    <div class="col col--last skills">
      Sketch and HTML.
    </div>
  </div>
</div>

<div class="table table--code u-separator">
  <p class="u-align-left">1) Use <strong>display: flex</strong> in the container.</p>
  <p class="u-align-left">2) Use <strong>flex-shrink</strong> in those datas less relevant and set a <strong>min-width</strong> for them.</p>
  <p class="u-align-left">3) Use ellipsis to let the user know there is more content.</p>
  </p>
</div>


              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Open+Sans');

$ellipsis-maxwidth: 100%;

@mixin ellipsis($max-width: $ellipsis-maxwidth) {
  @if $max-width == false {
    @warn "Maybe you should define a max width.";  
  }
  max-width: $max-width;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  padding: 50px;
  text-align: center;
  color: #333;
  background: #fff;
  font: 12px/1.5 'Open Sans', sans-serif;
  width: 800px;
}

strong {
  padding: 0 4px;
  background: #333;
  color: white;
}

.table {
  width: 100%;
  margin-top: 20px;
  border: 1px solid #ddd;
  overflow: hidden;
  
  &--code {
    padding: 20px;
    border-width: 4px;
    border-style: dotted;
  }
}

.row {
  display: flex;
  border-bottom: 1px solid #ddd;
  
  &--last {
    border-bottom: none;
  }
}

.col {
  @include ellipsis;
  padding: 10px;
  border-right: 1px solid #ddd;
  
  &--last {
    border-right: none;  
  }
}

.asset-1 {
 min-width: 10%;
 background: lighten(yellow, 30%);
}

.asset-2 {
  min-width: 100px;
  flex-shrink: 9999; 
}

.jobbies {
  min-width: 20px;
  flex-shrink: 10000;   
}

.number-id {
  min-width: 50px;
  flex-shrink: 100;  
}

.u-separator {
  margin-top: 40px;
}

.u-align-left {
  text-align: left;
}

              
            
!

JS

              
                
              
            
!
999px

Console