Reputation: 4243
This is my current work:
.sec {
color: red;
width: 200px;
}
<div style="height: 100px;">
<div class="sec">
Big textBig textBig textBig textBig textBig textBig text Big text Big textBig textBig textBig textBig text text Big textBig textBig textBig text Big textBig textBig textBig Big textBig textBig textBig textBig textBig textBig textBig textBig text
</div>
</div>
<div style="height: 100px; background-color: black;">
</div>
I want that the red text clips before overflow the black div and ends with '...'. How I do it?
Upvotes: 0
Views: 40
Reputation: 1531
Try update your css with below code
.sec {
color: red;
width: 200px;
overflow: hidden; /* Newly added */
text-overflow: ellipsis; /* Newly added */
display: -webkit-box; /* Newly added */
-webkit-line-clamp: 4; /* Newly added */
-webkit-box-orient: vertical; /* Newly added */
}
OUTPUT
Upvotes: 1
Reputation: 752
You just do overflow: hidden on the your parent element:
.sec {
color: red;
width: 200px;
}
<div style="height: 100px; overflow:hidden">
<div class="sec">
Big textBig textBig textBig textBig textBig textBig text Big text Big textBig textBig textBig textBig text text Big textBig textBig textBig text Big textBig textBig textBig Big textBig textBig textBig textBig textBig textBig textBig textBig text
</div>
</div>
<div style="height: 100px; background-color: black;">
</div>
Upvotes: 0