JSFiddle - React, Tailwind, and code Playground
by hibinyru
HTML
<div class="block">
Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом. Первый блок с большим текстом.
</div>
<a href="#" class="button">Показать блок</a>
CSS
.block {
height: 50px;
overflow: hidden;
position: relative;
}
.block.opener {
height: auto;
}
.block:after {
content: "";
width: 100%;
left: 0;
position: absolute;
height: 40px;
bottom: 0;
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%);
}
.block.opener:after {
opacity: 0;
}
JavaScript
$(document).ready(function(){
$('.button').click(function(){
$(this).prev('.block').toggleClass('opener');
$(this).css({"display":"none"});
});
});