Skip to content

trungdq88/css-flexbox-text-ellipsis

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

CSS Flexbox Text Ellipsis

Use: min-width: 0, text-overflow: ellipsis and white-space: nowrap.

HTML

  <div class="target">
    <div class="target-title">
      Text here is very very long that it might
      get truncate if this box get resized too small
    </div>
    <div class="target-button">
      Button
    </div>
  </div>

CSS

  .target {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }

  .target-title {
    overflow: hidden;
    padding: 5px;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .target-button {
    padding: 5px 10px;
    background: #2196F3;
    color: white;
  }

Releases

No releases published

Packages

No packages published