Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2006
    Posts
    12,405
    Tokens
    0

    Latest Awards:

    Default Is it possible to make a div background change on rollover?

    Here's my div:

    div#nav_1 {width: 35px; height: 71px; margin-right: auto; float: left; background: url("images/nav_1_before.gif");}


    And I want it to rollover with "images/nav_1_after.gif"

    +rep for help .
    Last edited by Black_Apalachi; 11-11-2008 at 01:45 PM.

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

    Latest Awards:

    Default

    div#nav_1:hover { new properties for the rollover here }

    so:


    div#nav_1 {width: 35px; height: 71px; margin-right: auto; float: left; background: url("images/nav_1_before.gif");}
    div#nav_1:hover { background: url("images/nav_1_after.gif"); }


    www.fragme.co = a project.

  3. #3
    Join Date
    Oct 2006
    Posts
    12,405
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Source View Post
    div#nav_1:hover { new properties for the rollover here }
    I think I tried something like that. Does that just go under the first div? Then do I need to add anything in the <body> tags?

    Edit: yay it works thank you!! +rep
    Last edited by Black_Apalachi; 11-11-2008 at 01:48 PM.

  4. #4

    Default

    div#nav_1
    {
    width: 35px;
    height: 71px;
    margin-right: auto;
    float: left;
    background: url("images/nav_1_before.gif");
    }

    div#nav_1:hover
    {
    background: url("images/nav_1_after.gif");
    }
    In Sources example there is something you should pay attention to, by using the shorthand background property to change the background you reset all the other background properties you may have specified on the default element, such examples is background-position, background-repeat, background-color, etc. So in the following example I've pasted here;

    http://pastebin.me/4919a01d20728

    You can see one the first div when hovering over and using the shorthand background property the background goes from black to white on hover, this is because the default background color is white.

    To avoid such results you should use background-image or redefine all the values in the shorthand background - I suggest using background image. If you look at the second one which is using background-image, you don't get this result, it keeps all it's properties.

  5. #5
    Join Date
    Oct 2006
    Posts
    12,405
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    In Sources example there is something you should pay attention to, by using the shorthand background property to change the background you reset all the other background properties you may have specified on the default element, such examples is background-position, background-repeat, background-color, etc. So in the following example I've pasted here;

    http://pastebin.me/4919a01d20728

    You can see one the first div when hovering over and using the shorthand background property the background goes from black to white on hover, this is because the default background color is white.

    To avoid such results you should use background-image or redefine all the values in the shorthand background - I suggest using background image. If you look at the second one which is using background-image, you don't get this result, it keeps all it's properties.
    Oh ok, thanks. +rep .

    If there aren't any other background properties, would this still be neccessary? The only properties are for the div itself:

    div#nav_1 {width: 35px; height: 71px; margin-right: auto; float: left; background: url("images/nav_1_before.gif");}
    ....or is this the same thing as what you're saying?

Posting Permissions

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