Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<div class="parent">
  <span class="name">
    Short text
  </span>
  <span class="number">
    1
  </span>
</div>
<div class="parent">
  <span class="name">
    Longer text
  </span>
  <span class="number">
    12
  </span>
</div>
<div class="parent">
  <span class="name">
    Very very long text
  </span>
  <span class="number">
    123
  </span>
</div>
 
html{
  font: 140% sans-serif;
}
.parent {
  background: #ddd;
  margin-bottom: 0.5em;
  padding: 0.3em;
  
  /* Use Flexbox layout and set a fixed width */
  display: flex;
  width: 8em;
}
.name {
  margin-right: 0.5em;
  
  /* Make width shrinkable beyond width of content */
  flex: 0 1 auto;
  
  /* Make sure text doesn't wrap or push beyond element boundaries */
  overflow: hidden;
  white-space: nowrap;
  
  /* Show an ellipsis when text cuts off */
  text-overflow: ellipsis;
}
.number {
  /* Make width inflexible */
  flex: 0 0 auto;
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers