Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <div class="widget">
  <div class="widget__header">
    <div class="widget__title">Text Truncation with CSS Ellipsis</div>
    <div class="widget__actions">
      <a href="" target="_blank">Learn More</a>
    </div>
  </div>
  <div class="widget__content">
    <pre><code>p {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  width: fit-content;
  white-space: nowrap;
}</code></pre>
    <pre><code>.container {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}</code></pre>
  </div>
  <div class="widget__content">
    <p class="max-width">Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
    
    <div class="container">Maecenas sed diam eget risus varius blandit sit amet non magna. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Donec sed odio dui. Sed posuere consectetur est at lobortis. Maecenas faucibus mollis interdum.</div>
  </div>
</div>

              
            
!

CSS

              
                .widget {
  background-color: var(--color-white);
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--global-radius);
  display: grid;
  grid-template-areas: "title"
    "left"
    "right";
  grid-template-columns: 100%;
  margin-left: auto;
  margin-right: auto;
  max-width: 90rem;
  width: 100%;
  
  @media (min-width: 768px) {
    grid-template-areas: "title title"
    "left right";
    grid-template-columns: 50% 50%;
  }
  
  &__header {
    align-items: center;
    border-bottom: 1px solid var(--color-neutral-300);
    display: flex;
    grid-area: title;
    justify-content: space-between;
  }
  
  &__title,
  &__content {
    padding: calc(var(--global-padding) * 2);
  }
  
  &__actions {
    padding-right: calc(var(--global-padding) * 2);
    
    a {
      background-color: var(--color-info);
      border-radius: var(--global-radius);
      color: var(--color-white);
      font-size: var(--size-xs);
      padding: calc(var(--global-padding) / 1.5) calc(var(--global-padding) * 1.5);
      text-decoration: 0;
      transition: all var(--global-transition-timing);
      
      &:hover {
        opacity: 0.8;
      }
    }
  }
  
  &__title {
    font-size: var(--size);
    font-weight: var(--bold);
  }
  
  &__content {
    &:nth-child(even) {
      border-right: 1px solid var(--color-neutral-300);
    }
  }
}

pre {
  margin-bottom: 1rem;
}

// Demo styles
.max-width {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  width: fit-content;
  white-space: nowrap;
}

.container {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}
              
            
!

JS

              
                
              
            
!
999px

Console