22 Aug 2015

How to create SPRITES using just HTML CSS

First just create HTML file as given here:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="css/primary.css">
    </head>
    <body>
        <ul class="button">
            <li class="info"></li>
            <li class="multi"></li>
            <li class="fast"></li>
        </ul>
    </body>
</html>

Create CSS file and attach file as given here:

.button{
    list-style: none;
    margin: 0;
    padding: 0;
}
.button li{
    width: 50px;
    height: 50px;
    display: inline-block;
    background-color: #aaa;
    margin-right: 10px;       
}
.button li.info{
    background: url(../images/sprite.png) no-repeat;
}
.button li.multi{
    background: url(../images/sprite.png) no-repeat -50px;
}
.button li.fsat{
    background: url(../images/sprite.png) no-repeat -100px;
}
.button li:hover{
    background: url(../images/sprite.png) no-repeat -100px;
}
Share:

0 comments:

Post a Comment