На демонстраций представлен материал на SCSS, возможно кто то переведет на рельсы CSS, сам пробовал, кажется без ощибок, но не так уже показывает на мобильном экране.
Код
<div class="postCardWrap">
<div class="post-card">
<div class="postContent">
<img class=" postImg" src="https://res.cloudinary.com/hashnode/image/upload/w_600,h_236,c_thumb/v1477832292/fcnah6pqrbcp02qel9eo.png" />
<h2 class="post-title">Zero to One: How I mastered JavaScript and how you can too</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div class="post-card">
<div class="postContent">
<img class="postImg" src="https://res.cloudinary.com/hashnode/image/upload/w_600,h_236,c_thumb/v1478866829/yhqpynmzrafvn7ps9grz.jpg" />
<h2 class="post-title">Zero to One: How I mastered JavaScript and how you can too</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div class="post-card">
<div class="postContent">
<img class="postImg" src="https://res.cloudinary.com/hashnode/image/upload/w_600,h_236,c_thumb/v1485155270/mqvfs6glo9dmoahwhbsu.png" />
<h2 class="post-title">Zero to One: How I mastered JavaScript and how you can too</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
SCSS
Код
body {
background: #fafafa;
margin: 0;
padding: 0;
}
* {
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;
}
.postCardWrap {
min-height: 100vh;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
.post-card {
width: calc(100% / 3 - 4);
padding: 12px;
margin: 8px;
border: #e0e0e0;
background: #fff;
box-shadow: 0 0 3px 0 rgba(0,0,0,.1);
border-radius: 3px;
box-sizing: border-box;
.postImg {
width: 100%;
border-radius: 3px;
}
.post-title {
font-size: 18px;
font-weight: 600;
line-height: normal;
margin: 0 0 12px;
}
p {
font-size: 15px;
color: #555;
margin: 0;
line-height: 1.4;
// Line clamp code
-webkit-box-orient: vertical;
display: -webkit-box;
-webkit-line-clamp: 4;
overflow: hidden;
}
@media (max-width: 768px) {
width: calc(100% / 2 - 4);
}
@media (max-width: 470px) {
width: calc(100% - 8);
}
}
}