I am trying to create a text fade-out effect when the amount of text is bigger than the row can handle. I am achieving this with the mixture of max-height
,
I think your are looking for something like this, right?
http://jsfiddle.net/QPFkH/
.text {
position:relative;
width:200px;
max-height:10em;
overflow:hidden;
}
.shadow {
position:absolute;
top:8em;
width:100%;
height:2em;
background: -webkit-linear-gradient(transparent, white);
background: -o-linear-gradient(transparent, white);
background: -moz-linear-gradient(transparent, white);
background: linear-gradient(transparent, white);
}
If you don't need to rely on percentage values, use box-shadow
instead of background-image
. It makes it possible to let the user interact with the elements behind your fading-thingy, without the need of pointer-events: none
(http://caniuse.com/#feat=pointer-events):
box-shadow: 0 0 2em 1em #f00;
height: 0;
But be warned, box-shadow can slow down scrolling: