Smoothly leaving text

Do not tell me how to make such a smoothly leaving text when you click on a link (or button), and that the text would be half as transparent as on the screenshot. I hope for your help, thank you very much)

  • four
    This is not a translucent text. This is an overlay on the text block with a translucent gradient. - Pyramidhead

2 answers 2

$('.open').click(function() { $('.box').toggleClass('box-activ'); }); 
 .box { margin: 0 auto; width: 700px; height: 100px; overflow: hidden; transition: all 0.5s; display: block; position: relative; box-sizing: border-box; } .box:after { content: ''; position: absolute; width: 100%; height: 110px; background: linear-gradient(to top, white, rgba(0, 0, 255, 0)); left: 0px; bottom: 0px; } .box-activ { height: 200px; transition: all 0.5s; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="box"> <p>Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне. Lorem Ipsum является стандартной "рыбой" для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p> </div> <p class="open">Открыть</p> 

     'use strict'; var linkMore = document.querySelector('.link-more'), text = document.querySelector('.text'); linkMore.onclick = function(e) { e.preventDefault(); text.classList.toggle('text-open'); } 
     .text { max-height: 105px; overflow: hidden; position: relative; transition: max-height 0.5s cubic-bezier(0, 1, 0, 1); } .text:after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 1) 100%); pointer-events: none; } .text-open { max-height: 999px; transition: max-height 1s ease-in-out; } .text-open:after { display: none; } 
     <div class="text"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </div> <a href="#" class="link-more">Reed more</a>