Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: CSS :hover

  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS :hover

    I'm working on a php/AJAX script thats pulls information into the current page into a div with id="results". I have the following CSS:
    Code:
    #results {
    	padding: 5px;
    }
    	div#results div {
    		padding: 5px;
    	}
    	div#results div span {
    		float: right;
    		font-weight: normal;
    	}
    	div#results div:hover {
    		background-color: #ededed;
    	}
    My problem is that the very last div I have within the results div is not supposed to have a hover effect. Is there a way I can easily do this w/o having to make the code twice as long?

  • #2
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    Create a class for it too? Add this after the hover state you have there:

    Code:
    	div#results .thisone div:hover {
    		(style in here)
    	}
    Then put your class within the last id.
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,621
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Funny, I've never used that pseudo class because I always thought it wouldn't work/exist... very strange. Well, haven't tried it but try this:
    #results div:last-child:hover {background-color: [whatever the default color is];}
    Edit: Ah now I see... doesn't work properly in all browsers... again! That's why I never used it. http://www.quirksmode.org/css/firstchild.html
    Last edited by VIPStephan; 01-25-2007 at 12:04 PM.


  •  

    Posting Permissions

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