You can do this with CSS (without an image or extra markup) using a ::before
pseudo-element for the overlay, and linear-gradient
for the fade with rgba()
opacity from 0
to 1
. This assumes you don't need to click on the elements in the <div>
individually, since the overlay prevents that.
Demo: http://jsfiddle.net/ThinkingStiff/xBB7B/
Output:
CSS:
#overlay {
position: relative;
}
#overlay::before {
background-image: linear-gradient( top,
rgba( 255, 255, 255, 0 ) 0%,
rgba( 255, 255, 255, 1 ) 100% );
background-image: -moz-linear-gradient( top,
rgba( 255, 255, 255, 0 ) 0%,
rgba( 255, 255, 255, 1 ) 100% );
background-image: -ms-linear-gradient( top,
rgba( 255, 255, 255, 0 ) 0%,
rgba( 255, 255, 255, 1 ) 100% );
background-image: -o-linear-gradient( top,
rgba( 255, 255, 255, 0 ) 0%,
rgba( 255, 255, 255, 1 ) 100% );
background-image: -webkit-linear-gradient( top,
rgba( 255, 255, 255, 0 ) 0%,
rgba( 255, 255, 255, 1 ) 100% );
content: "0a0";
height: 100%;
position: absolute;
width: 100%;
}
HTML:
<div id="overlay">
<span>some text</span><br />
<img src="http://thinkingstiff.com/images/matt.jpg" width="100" /><br />
<p>some more text</p>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…