Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="box">
  <input type="checkbox" id="expanded">
  <p>Hey, don't cut me off like that. I want to speak my mind and don't appreciate being put into a box.</p>
  <!-- Note: I have sadly not found a nice way to put the more button/label inline inside the paragraph, after or before the ellipsis. -->
  <label for="expanded" role="button">read more</label>

<footer>Inspired by <a href="">Geoff's demos</a></footer>
              .box {
  input {
    opacity: 0;
    position: absolute;
    pointer-events: none;
  p {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;  
    overflow: hidden;
  input:focus ~ label {
    outline: -webkit-focus-ring-color auto 5px;
  input:checked + p {
    -webkit-line-clamp: unset;
  input:checked ~ label,
  p:not(.truncated) ~ label{
    display: none;

/* From here on presentation styles */
body {
  align-items: center;
      farthest-side at bottom left,
      rgba(255, 0, 255, 0.5), 
      farthest-corner at bottom right,
      rgba(255, 50, 50, 0.5), 
      #246756 400px
  display: flex;
  flex-direction: column;
  height: 100vh;
  justify-content: center;
  line-height: 1.5;

.box {
  background-color: #fff;
  box-shadow: 2px 2px 10px #246756;
  padding: 2em;
  width: 15vw;
  max-width: 250px;
  min-width: 150px;
  p {
    margin: 0;
  label {
    border-radius: 4px;
    padding: 0.2em 0.6em;
    border: 1px solid #009ce2;
    background-color: #00acff;
    color: #fff;
    font-size: 0.8em;

footer {
  margin-top: 2em;
  color: #ffffff66;
  a {
    color: #fff;
 * Since the pseudo class :truncated is sadly not a thing, if your truncated box is responsive or the text in the box is of arbitrary size, the following code adds or removes a "truncated" class to simulate the feature.
 * Warning: Doesn't work in all browsers due to the use of ResizeObserver, use something like the window's resize event if you need it to be moar cross browser.
const ps = document.querySelectorAll('p');
const observer = new ResizeObserver(entries => {
  for (let entry of entries) {[ > entry.contentRect.height ? 'add' : 'remove']('truncated');

ps.forEach(p => {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.