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

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.

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

              
                <input type="checkbox" id="trim" checked><label for="trim">CSS Trim Text</label>

<ul class="common-posts">
  <li class="common-posts-item">
    <article class="card">
  <a href="https://elad.medium.com/trimming-multi-lines-in-css-5ae59d5e6d84" target="_blank">
    <div class="card-image">
      <img src="https://i2.wp.com/eladsc.com/wp-content/uploads/2019/12/1_c6c9KlQXopbKwh7Kiiz8og.png?w=880&ssl=1">
    </div>
    <div class="card-content">
      <h2>Trimming Multi-Line Text in CSS</h2>
      <p>
  Trimming lines of text in CSS has always been an issue in web development. Up until a few years ago, trimming lines could only be done by server-side languages or with JavaScript because CSS didn’t have a text trimming feature.
      </p>
    </div>
  </a>
</article>
  </li>
  <li class="common-posts-item">
    <article class="card">
      <a href="https://elad.medium.com/how-does-css-work-92fe7116916d" target="_blank">
        <div class="card-image">
          <img src="https://i0.wp.com/eladsc.com/wp-content/uploads/2021/01/how-does-css-works.png">
        </div>
        <div class="card-content">
          <h2>How Does CSS Work?</h2>
          <p>
When you start creating a new website, even before writing a single style, the browser applies styles to it — its default styles.<br><br>
            Have you ever asked yourself who decides what those basic default styles will be?

          </p>
        </div>
      </a>
    </article>
  </li>
  <li class="common-posts-item">
    <article class="card">
      <a href="https://elad.medium.com/new-css-logical-properties-bc6945311ce7" target="_blank">
        <div class="card-image">
          <img src="https://i0.wp.com/eladsc.com/wp-content/uploads/2019/11/1_hqumXaLjidnm_AKK5bdVxg-1.png">
        </div>
        <div class="card-content">
          <h2>The New CSS Logical Properties!</h2>
          <p>
Most of us developers used to think in terms of left and right, top and bottom. This is because in the early days of the internet, it was meant mostly for uploading documents, and not for the complex website structures we know today.
This is the reason that no one considered the needs of multiple language websites.
          </p>
        </div>
      </a>
    </article>
  </li>
</ul>
              
            
!

CSS

              
                :checked ~ .common-posts{
  p{
    /* Trim Text*/
      display: -webkit-box;   
      -webkit-line-clamp: 3;   
      -webkit-box-orient: vertical;       
      overflow: hidden; 
    
    animation:focus 0.8s;
  }
}





html{
  line-height:1.4;
  font-family:sans-serif;
}
.common-posts{
  display:grid; grid-gap:30px;
      &-item:nth-child(even){
        .card a{flex-direction:row-reverse;}
      }
}
.card{
  background-color:#fff;
  box-shadow:0 0 7px -1px rgba(#000, .1);
  border-radius:5px;
  margin:0 auto;
  max-width:950px;
  a{
    &:focus, &:hover{
      box-shadow: 0 0 7px -1px rgba(#000, .35);
    }
  }
  &-image{}
  &-content{
    padding:20px;
    h2{
      font-family:Poppins, sans-serif; font-size:27px; line-height:1.2; margin-top:0; margin-bottom:10px;
      &::after{
        content:""; display:block; height:5px; width:35px;
        background:#5ad67d; border-radius: 3px; margin-top:10px;
      }
    }
    p{}
  }
  @media (max-width:790px){
    
  }
  @media (min-width:791px){
    a{display:flex;}
    &-image{display:flex; align-items:flex-start; width:400px; flex-shrink:0;}
  }
}



html{font-family:arial; background: #f1f1f1;}
body{margin:30px;}
img{max-width:100%;}
ul, li{list-style:none; padding:0; margin:0;}
p{margin:0; font-size:24px;}
a{color:inherit; text-decoration:none;}


input{
  position:fixed; top:20px; left:15px; z-index:11;
  display:block; padding:5px; border:solid 1px rgb(136 136 136 / 0.7); border-radius:4px;
  background-color:rgb(255 221 64 / 0.8);
  margin-right:5px;
}
label{
  position:fixed; z-index:10; left:10px; top:10px;
  display:block; padding:10px; padding-left:30px; border-radius:4px;
  background-color:rgb(255 221 64 / 0.8);
}


@keyframes focus{
  50%{background-color:rgb(90 214 125 / 0.35);}
}
              
            
!

JS

              
                
              
            
!
999px

Console