Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default Rollover Image with CSS

    Hey,
    I wonder if anyone knows the CSS and HTML codes of how to create a rollover image.
    I don't want it to be a simple, with images. I want it to be two backgrounds, with text over them.
    The text should be edit-able.

    Do you know what I mean?
    Something like www.smashingmagazine.com they're rollover navigation at top.

  2. #2
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

  3. #3
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    Gahh. I'm not a good source viewer

  4. #4
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

    Default

    HTML Code:
    <div id="header">
    <ul>
    	<li><a title="Home" href="http://www.smashingmagazine.com/" class="home">Home</a></li>
    	<li><a title="Graphics" href="http://www.smashingmagazine.com/category/graphics/" class="graphics">Graphics</a></li>
    	<li><a title="Showcases" href="http://www.smashingmagazine.com/category/showcase/" class="showcases">Showcases</a></li>
    	<li><a title="Monday Inspiration" href="http://www.smashingmagazine.com/category/monday-inspiration/" class="monday-inspiration">Inspiration</a></li>
    	<li><a title="Fonts" href="http://www.smashingmagazine.com/category/fonts/" class="fonts">Fonts</a></li>
    	<li><a title="How-To" href="http://www.smashingmagazine.com/category/know-how/" class="know-how">How-To</a></li>
    	<li><a title="CSS" href="http://www.smashingmagazine.com/category/css/" class="css">CSS</a></li>
    	<li><a title="Tools" href="http://www.smashingmagazine.com/category/toolbox/" class="toolbox">Tools</a></li>
    	<li><a title="Freebies" href="http://www.smashingmagazine.com/category/freebies/" class="freebies">Freebies</a></li>
    	<li><a title="Tutorials" href="http://www.smashingmagazine.com/category/tutorials/" class="tutorials">Tutorials</a></li>
    	<li><a title="Jobs" href="http://jobs.smashingmagazine.com" class="jobs">Jobs</a></li>
    </ul></div>
    Now check the style sheets for header.li.hover or whatever.

  5. #5
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    Thanks I think i found the .css file. But my internet shuts down every time i try accessing it? :S

    http://www.smashingmagazine.com/wp-c...genavi-css.css

  6. #6
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Best way todo this would be 2 images, you can do it in 1 and use co-ordinates to load a different part for rollover, but thats just a pain.

    So here:

    HTML Code:
    /* This is for a .CSS */
    
    .buttonhome {
          background: url(/images/normalhome.png);
    }
    
    .buttonhome:hover {
          background: url(/images/rolloverhome.png);
    }
    That should help you get a jist for it


    www.fragme.co = a project.

  7. #7
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Umm its more user-friendly if you do the graphics for the rollover images on top of each other, then just set the background-position to bottom to use the second image on the .class:hover{ } attrib.
    Coming and going...
    Highers are getting the better of me

  8. #8
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

    Default

    Quote Originally Posted by MrCraig View Post
    Umm its more user-friendly if you do the graphics for the rollover images on top of each other, then just set the background-position to bottom to use the second image on the .class:hover{ } attrib.
    Yah, thats the easiest option or you might get confused with the li's etc.

  9. #9
    Join Date
    Jul 2005
    Location
    North Wales
    Posts
    4,233
    Tokens
    2,009

    Latest Awards:

    Default

    Quote Originally Posted by MrCraig View Post
    Umm its more user-friendly if you do the graphics for the rollover images on top of each other, then just set the background-position to bottom to use the second image on the .class:hover{ } attrib.
    Or you could add the image into a hidden div or a div with 0 height and width then the image is already preloaded, but you way works the same.

  10. #10
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    Should this work:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled</title>
    </head>
    <style>
    <!--
    .buttonhome {
          background: url(images/normal.png);
    }
    
    .buttonhome:hover {
          background: url(images/rollover.png);
    }
    -->
    </style>
    <body>
    <div id="buttonhome></div>
    <div id="buttonhome:hover></div>
    </body>
    </html>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •