School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,104 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,048 people online right now. Registration is fast and FREE... Join Now!




CSS Image Rollovers

 
Reply to this topicStart new topic

> CSS Image Rollovers

Dogstopper
Group Icon



post 30 Jul, 2009 - 02:27 PM
Post #1


Image Rollovers

All right, this tutorial is short and sweet but rather effective.
First you will need two different images to transition between; however, in CSS's case put them side-by-side and save it as the same single image , and it should be uploaded along with the rest of your site in the same directory as the html file.

HTML Code:
CODE

<a href="[i]link location[/i]" class="rollover" title="link"><span class="displace">Link</span></a>


This creates a link that if CSS is enabled will make the rollover button, and if CSS is disabled, then it creates a very simple link to the same place.

Now, for the CSS
CODE

a.rollover {
    display: block;
    width: [i]width/2[/i]px;
    height: [i]height/2[/i]px;
    text-decoration: none;
    background: url("img1.png");
}

a.rollover:hover {
    background-position: -150px 0;
}

.displace {
    position: absolute;
        [i]Wherever you want the image[/i]
}


All we do is we set the button to only display the first half of the button until the user rolls over it with the mouse and then it displays only the second half.

See! I told you this tutorial was short and sweet. Best wishes!
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 11/21/09 12:36PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month