<div class="block-with-text">
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.
</div>
CSS
/* стили для мноточия '…' */
.block-with-text {
/* спрятать текст если у более N строк */
overflow: hidden;
/* для установки '…' в абсолютную позицию */
position: relative;
/* используйте это значение для расчёта высоты блока */
line-height: 1.2em;
/* max-height = line-height (1.2) * число строк (3) */
max-height: 3.6em;
/* исправлиление проблемы когда последнее слово не соединяется с правой стороны */
text-align: justify;
/* место для многоточия '…' */
padding-right: 1em;
}
/* создаём многоточие … */
.block-with-text:before {
/* многоточие в конце */
content: '…';
/* абсолютное позиционирование */
position: absolute;
/* установить позицию в правый нижний угол блока */
right: 0;
bottom: 0;
}
/* спрятать многоточие … если у нас есть текст, который меньше или равен количеству максимальный строк */
.block-with-text:after {
content: "";
position: absolute;
/* установить позицию в правый нижний угол блока */
right: 0;
/* установить width и height */
width: 1em;
height: 1em;
margin-top: 0.2em;
/* цвет фона перед блоком */
background: white;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.