Skip to main content

How to use CSS Sprites.

I am not a web designer but i needed to show a before and after state for my restoration images. I had originally started with 2 images 'before' and 'after' side by side. This achieved the goal but didn't really give any wow factor.

I then tried a roll-over technique where holding the mouse over the image loads up a different one. But that meant the second image didn't load until the mouse was placed over it.

The solution was to use a CSS  sprite. This loads just one image made up of the before and after images. The clever bit is that the code only displays one half of the image. When the mouse is moved over it it shifts the image's position on the page to show the other half. But as it is still ALL one image it doesn't require any time to load it. Instant before and after states. Below is the original image and the CSS code I used. You can see the final result on the restoration page




You can see the final result on the restoration page

<-!
<center><style>#BIKE
{
  displayblock;
  width215px;
  height300px;
  backgroundUrl(http://www.pixelfix.co.nz/resources/Bikesprite.jpgno-repeat 0px 0px
border-style:solid;
border-width:7px;
border-color:#FFFFFF;
}

#BIKE:hover

  background-position-215px 0px;
}

#BIKE span
{
  displaynone;
    }
</style>
<id="BIKE" href="#" title="BIKE"><span>BIKE</span></a></center>


​->

Comments

Popular posts from this blog

Fancy new views for the blog page.

This blog page is powered by blogger and they have just provided some new interactive ways to view the blog posts. To view all this new fanciness you must go to http://blog.pixelfix.co.nz/view I will place a link for this view at the bottom of each post and also on the PixelFIX Facebook page. Below is a small video showing some of the different ways you can view the photo restoration blog at PixelFIX. PixelFIX - Photo restoration and photos repaired, from $15. The restoration and manipulation specialists.

Statistics for photo restoration blog.

Happy Friday to all, something a little different today. Below is some geeky stuff relating to what software people use to browse the internet with. The first graph shows what people use to view the pages of PixlFIX Photo rBlog.  The second chart shows the world wide usage of different browsers. As you can see viewers of PixelFIX Photo Restoration Blog are quite evenly split. Specific data relating to PixelFIX Blog. Pageviews by Browsers Internet Explorer 44 (34%) Chrome 39 (30%) Firefox 39 (30%) Safari 3 (2%) Mobile 2 (1%) Opera 1 (<1%) General web statistics worldwide. Web Statistics and Trends Statistics are important information. From the statistics below, you can see that Firefox, Internet Explorer, and Chrome are the most popular browsers today. Browser Statistics Month by Month 2011 Internet Explorer Firefox Chrome Safari Opera February 26.5 % 42.4% 24.1% 4.1% 2.5% January 26.6 % 42.8% 23.8% 4.0% 2.5%       ...

Restoring badly torn photograph

This has to be one of the most satisfying restorations done to date. The original was torn into many pieces and required extensive Photoshop work to be painstakingly pieced back together. The original scan was the key to making this a successful restoration and invisibly repairing the ripped pieces into one full image again. PixelFIX - Photo restoration and photos repaired, from $15. The restoration and manipulation specialists. Click here for 'fancy view'