html - Is there a way to fade just the text of a div when the div has a partially transparent background -
i trying create "read more" fade effect on text when overflows container. easy when text on solid background. can have overlay div linear gradient transparency in same color background.this makes text fading background
however text on partially transparent background. transparency of overlay stacks on top of background making background appear fade along text. here js fiddle of problem: https://jsfiddle.net/b0p6lozv/2/
my desired effect have background color consistent throughout div , have text fade out towards bottom of div. possible create gradient on foreground colors of div? help!
here code
<div class="pagebody"> <div class="wrapper"> <div class='container'> <p>line1</p> <p>line2</p> <p>line3 line3 line3 line3</p> <p>line4</p> </div> <div class="overlay"> </div> </div> </div> <div class="pagebody"> <div class="wrapper2"> <div class='container'> <p>line1</p> <p>line2</p> <p>line3 line3 line3 line3</p> <p>line4</p> </div> <div class="overlay2"> </div> </div> </div> .pagebody { background: black; } .wrapper { position: relative; background: rgba(255, 255, 255, 0.6); } .container { height: 100px; overflow: hidden; } .overlay { position: absolute; width: 100%; bottom: 0; height: 40px; background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6));
can use html5?
get rid of overlay div , css style .container div.
you use clipping-path or mask.
mask
.container { etc... mask: url(mask.svg) top left / cover; } clipping path
.container { etc... clip-path: url(#clippingpathimage); } the clip-path property can applied html elements... clippath element or 1 of basic shapes introduced css exclusions.
more info: http://www.html5rocks.com/en/tutorials/masking/adobe/
Comments
Post a Comment