Home
PHP
Tech Tube
MySQL
Linux
CSS&HTML
JavaScript

CSS overlay

Here's a simple but effective CSS overlay. It has a box on top of the overlay that could be used as popup or loading indicator. A simple demo:
The overlay CSS:
<style>
#overlay {
    display:none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    filter:alpha(opacity=50);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5;
    z-index: 10000;
}
#loading {
    display:none;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 100px;
    line-height: 100px;
    font-size:33px;
    margin-left:-150px;
    margin-top:-50px;
    background-color: #fff;
    z-index: 10001;
    color: #4286f4;
    text-align:center;
}
</style>
The HTML code:
<div id="overlay"></div>
<div id="loading"><button id="hide_overlay">hide overlay</button></div>
<button id="show_overlay">show overlay</button>
Some javascript useful for testing:
<script>
jQuery( document ).ready(function($) {
    $('#show_overlay').click(function(){
	$('#overlay').css('display','block');
	$('#loading').css('display','block');
    });
    $('#hide_overlay').click(function(){
	$('#loading').css('display','none');
	$('#overlay').css('display','none');
    });
});
</script>