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="card-deck p-5 m-5">
  <div class="card">
    <img src="https://images.unsplash.com/photo-1505245208761-ba872912fac0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80" class="card-img-top" alt="...">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <p class="card-text ellipsize-element lines-3">Suspendisse commodo dapibus mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque hendrerit efficitur dapibus. Integer ac dui pellentesque, egestas lectus sed, posuere mauris. Donec consectetur et felis vel interdum. Vestibulum efficitur vestibulum lorem, at ornare risus consectetur sed.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
  </div>
  <div class="card">
    <img src="https://images.unsplash.com/photo-1437422061949-f6efbde0a471?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80" class="card-img-top" alt="...">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <p class="card-text ellipsize-element lines-3">Nullam sodales sodales ultricies. Nam ac tortor dui. </p>
      <p class="card-text"><small class="text-muted">Last updated 5 mins ago</small></p>
    </div>
  </div>
  <div class="card">
    <img src="https://images.unsplash.com/photo-1446488547543-78c11468449a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1049&q=80" class="card-img-top" alt="...">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <p class="card-text ellipsize-element lines-3">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum finibus diam mauris, nec aliquam odio facilisis sed. Phasellus leo tortor, pretium in nisi vitae, bibendum imperdiet odio. </p>
      <p class="card-text"><small class="text-muted">Last updated 1 mins ago</small></p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @mixin limitTextToLineNumbersMixin( $font-size: $font-size-base, $line-height: 1.4, $lines-to-show: 3 ) {
  max-width: 100%;
  height: calc(#{$font-size} * #{$line-height} * #{$lines-to-show});
  font-size: $font-size;
  line-height: $line-height;
  overflow: hidden;
}

body{
  background: lightgray;

    @for $lines from 1 to 6 {
      .ellipsize-element.lines-#{$lines} {
        @include limitTextToLineNumbersMixin( 1rem, 1.5, #{$lines})
      }
  }
}
              
            
!

JS

              
                (function() {
  'use strict';

  // Variables
  var element = '.ellipsize-element';
  var $ellipsizeElement = $(element);

  // Methods

  function ellipsizeTextElement(element) {
    var nodeList = document.querySelectorAll(element);
    var elements = Array.prototype.slice.call(nodeList, 0);
    elements.forEach(function(element) {
      var wordArray = element.innerHTML.split(' ');
      while (element.scrollHeight > element.offsetHeight) {
        wordArray.pop();
        element.innerHTML = wordArray.join(' ') + '...';
      }
    });
  }

  if ($ellipsizeElement.length) {
    ellipsizeTextElement(element);
  }
})();
              
            
!
999px

Console