<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>
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);
}


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


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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://assets.codepen.io/65740/twitter.js