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

              
                <p>Consider a flex container in which one of the children has text that is truncated using white-space: nowrap; overflow: hidden; and text-overflow: ellipsis. Intuitively, we might expect the text to be truncated as the size of the flex container decreases.</p>

<div class="tile">
  <a class="action" href="#">
    <div class="subtitle">
      Some text that will be too long, and should be truncated using CSS for responsiveness.
    </div>
  </a>
  <a class="action action--r" href="#">
    <div class="sibling">&lt;sibling&gt;</div>
  </a>
</div>

<div class="tile" style="max-width: 600px">
  <a class="action" href="#">
    <div class="subtitle">
      Some text that will be too long, and should be truncated using CSS for responsiveness.
    </div>
  </a>
  <a class="action action--r" href="#">
    <div class="sibling">&lt;sibling&gt;</div>
  </a>
</div>

<div class="tile" style="max-width: 100px">
  <a class="action" href="#">
    <div class="subtitle">
      Some text that will be too long, and should be truncated using CSS for responsiveness.
    </div>
  </a>
  <a class="action action--r" href="#">
    <div class="sibling">&lt;sibling&gt;</div>
  </a>
</div>

<p>According to a <a href="http://dev.w3.org/csswg/css-flexbox/#min-size-auto">draft spec</a>, the above text should not fully collapse when the flex container is resized down. Because .subtitle has a width of 100%, the min-width: auto calculation that flexbox makes says that its container should be larger than we want. This behavior has made it to Firefox (as of 34), but not Chrome (as of 39). Note: it's an editor's draft, not a recommendation, at the time of writing.</p>

<p>In order to acheive the desired (arguably, intuitive) behavior, you have to give the text's container min-width: 0 (below).</p>

<div>
<div class="tile">
  <a class="action" href="#" style="min-width:0">
    <div class="subtitle">
      Some text that I just -know- will be too long, and should be truncated using CSS for responsiveness.
    </div>
    <div class="subtitle">
      Some text that I just -know- will be too long, and should be truncated using CSS for responsiveness.
    </div>
  </a>
  <a class="action action--r" href="#">
    <div class="sibling">&lt;sibling&gt;</div>
  </a>
</div>
</div>
              
            
!

CSS

              
                .tile
  border: 1px solid black
  display: flex
  margin: 1em 0

.action
  border: 1px dashed black
  color: black
  flex-shrink: 1
  flex-grow: 1
  max-width: 100%
  padding: 1em
  text-decoration: none

.action--r
  flex-grow: 0
  flex-shrink: 0

.subtitle
  display: inline-block
  width: 100%
  
  white-space: nowrap
  overflow: hidden
  text-overflow: ellipsis
              
            
!

JS

              
                
              
            
!
999px

Console