PSEUDO ELEMENTS

by danield770

HTML

<h2>Positioning one image on top of another in HTML using Pseudo elements</h2>

<div class="background"></div>

<div class="img"></div>

CSS

.background
{
    width: 100px;
    height: 100px;
    position: relative;
    background-color: blue;
}
.background:after
{
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 5px;
    left: 5px;
    background-color: red;
}

.img
{
    display: inline-block;
    width: 128px;
    height: 128px;
    position: relative;
    background: url(http://dl.dropbox.com/u/51558405/big.png) no-repeat;
}
.img:after
{
    content: '';
    display: inline-block;
    position: absolute;
    width: 48px;
    height: 48px;
    top: 40px;
    left: 40px;
    background: url(http://dl.dropbox.com/u/51558405/small.png) no-repeat;
}

h2
{
    margin: 20px;
    font-weight: bold;
}