Stackoverflow - How to apply a fade away effect (not animation) across all the content of a div?

http://stackoverflow.com/q/9204450/918414

by AndreaLigios

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>

CSS

#overlay {
    border: 1px solid black;
    display: inline-block;
    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: "\00a0";
    height: 100%;
    position: absolute;
    width: 100%;
}

JavaScript

/* by: thinkingstiff.com
license: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ */

var headerUri = 'http://stackoverflow.com/q/9204450/918414',
    headerCaption = 'How to apply a fade away effect (not animation) across all the content of a div?';
    
document.body.insertAdjacentHTML( 
    'afterBegin',
      '<a href="' + headerUri + '" '
    + 'target="_top" '
    + 'onmouseover="this.style.opacity=\'.95\'" '
    + 'onmouseout="this.style.opacity=\'1\'" '
    + 'style="'
        + 'background-color: black;'
        + 'background-image: linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
        + 'background-image: -webkit-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
        + 'background-image: -moz-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
        + 'background-image: -o-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
        + 'background-image: -ms-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
        + 'border: 1px solid black;'
        + 'border-radius: 2px;'
        + 'color: white;'
        + 'display: block;'
        + 'font: normal 15px/26px Helvetica, Verdana, Tahoma;'
        + 'height: 26px;'
        + 'left: 0px;'
        + 'opacity: 1;'
        + 'overflow: hidden;'
        + 'padding: 2px 8px;'
        + 'position: fixed;'
        + 'right: 0px;'
        + 'text-decoration: none;'
        + 'text-overflow: ellipsis;'
        + 'text-shadow: -1px -1px black;'
        + 'top: 0px;'
        + 'white-space: nowrap;'
        + 'z-index: 9999;'
    + '"><img '
    + 'style="' 
        + 'display: block;'
        + 'float: left;'
        + 'margin-right: 8px;" '
    + 'src="http://thinkingstiff.com/images/stackoverflow.png" />'
    + headerCaption
    + '</a>'
    );

document.body.insertAdjacentHTML( 
    'afterBegin', 
    '<a href="http://thinkingstiff.com" '
    + 'target="_top" '
    +...