put elements one above the other css code example

Example: view div over other divs

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Overlaying One DIV over Another DIV</title>
<style> 
    .container{
        width: 200px;
        height: 200px;
        position: relative;
        margin: 20px;
    }
    .box{
        width: 100%;
        height: 100%;            
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0.8;  /* for demo purpose  */
    }
    .stack-top{
        z-index: 9;
        margin: 20px; /* for demo purpose  */
    }
</style>
</head>
<body>
    <div class="container">
        <div class="box" style="background: red;"></div>
        <div class="box stack-top" style="background: blue;"></div>
    </div>
</body>
</html>

Tags:

Css Example