On a responsive web page, text heights grow as their width narrow. When needing visually consistent containers, setting the text height to a fixed number of lines can leave words hanging mid-sentence. Fading these words out is one way to gracefully suggest there's more to read, and it is easy to do using plain HTML and CSS.

In the above container, both the title and description are set to fade away. The text height will always be the same, but more text will show as the width expands.
Element CSS
- Adjust
font-size,line-heightandheightas needed. - Cut of extra text with
overflowcuts off extra text. - Sets the pseudo element context with
position-relative.
p {
font-size: 1rem;
height: 6rem;
line-height: 1.5;
overflow: hidden;
position: relative;
}
Pseudo element CSS
p:after {
background: linear-gradient(to right, rgba(255, 255, 255, 0), white 90%, white);
bottom: 0;
color: transparent;
content: "\02026";
font-size: 1rem;
position: absolute;
right: 0;
width: 12rem;
}
- Set the
backgroundtransparency curve, color and direction. positionthe pseudo element in theabsolutebottomrightcorner of the parent element.- Set text
colorto transparent. - Activate the pseudo element with
content. - Make pseudo element
font-sizesame as parent element. - Set
widthof gradient (assumes IE10+)
