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

              
                <h1>
   Three Ways to Hide Clamped Lines of Text
</h1>

<div class="wrapper">
   <div class="example example-1">
      <h2>
         Hidden Overflow
      </h2>

      <p>
         Oh God, one of them's loose. Um, I can't turn back...okay, I can do this. I am a matador. I fearlessly— Ah, Jesus! Shit! Fuck! Piss! Those things bite! Oh, I see. The button doesn't work. We design a lot like that, too. Don't try to haggle with me, you savages! All prices are final!
      </p>
   </div>
   <div class="example example-2">
      <h2>
         Scroll Overflow
      </h2>

      <p>
         So, what are my options here? I could shoot every one of these tentacle things individually, but then they would puke up so much this ramp would turn into a Slip 'n' Slide of blood, and I just washed that off of me—again! I have a doctor's degree! Looks like I'm the one stuck having to do training...ASS SLAPPAGE.
      </p>
   </div>
   <div class="example example-3">
      <h2>
         Visible Overflow
      </h2>

      <p>
         God, how many helicopters are there? Too damn many, that's how much. What, is that your buddy? Like the two of you were going to convince me of something? Whoa, what was that? Batter up. Strike one! Strike two! Strike...ah, it's raining men! I mean aliens! I was so close!
      </p>
   </div>
</div>
              
            
!

CSS

              
                :root {
   --white: #efefef;
}

body {
   display: flex;
   min-height: 100vh;
   padding: 1rem;
   align-items: center;
   justify-content: space-around;
   flex-direction: column;

   background: radial-gradient(
      farthest-side at bottom center,
      rgba(120, 2120, 255, 0.5),
      #240786
   );
}

h1 {
   color: var(--white);
}

.wrapper {
   display: flex;
   flex-wrap: wrap;
   align-items: center;
   justify-content: center;
}

.example {
   margin: 0.5rem;
   padding: 1rem;
   flex: 1 1 125px;

   background: var(--white);
   border: 1px solid black;
}

p {
   display: -webkit-box;
   -webkit-line-clamp: 3;
   -webkit-box-orient: vertical;
}

.example-1 p {
   overflow: hidden;
}

.example-2 p {
   overflow: scroll;
}

.example-3 p {
   overflow: visible;
}

h2 {
   margin-top: 0.5rem;
}

              
            
!

JS

              
                
              
            
!
999px

Console