Results 1 to 6 of 6

Thread: condense code

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default condense code

    can i some how combine this?
    Code:
    #square00 a:hover { background-color:#444; } 
    #square01 a:hover { background-color:#444; } 
    #square02 a:hover { background-color:#444; } 
    
    
    a.class_00:hover{ color:#444; } 
    a.class_01:hover{ color:#444; } 
    a.class_02:hover{ color:#444; }

  2. #2
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    Code:
    #square00 a:hover,#square01 a:hover,#square02 a:hover{background-color:#444;} 
    a.class_00:hover,a.class_01:hover,a.class_02:hover{color:#444;}
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you could list them all in a single statement:
    Code:
    #square00 a:hover, #square01 a:hover, #square02 a:hover, 
    a.class_00:hover, a.class_01:hover, a.class_02:hover{ color:#444; }
    or, it may be simpler to create another class to set the bg color:
    Code:
    .bg{ color: #444; }
    and apply it to all the elements you like.

    In this (for example):#square00 a:hover, is #square00 the id for the <a> or for the <a>'s parent? If #square00 is the <a> itself, then you can simply write #square00:hover. Likewise, if .class_00 is only used on <a> elements, then you don't have to specify that the class belongs to the a element.

  4. #4
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    Traq - one set is for background-color and the other is for color

    Cheers

    GW
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  5. #5
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    thank you for the response, i have a class set already but this gave ideas
    thanks again
    cheers

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by gwmbox View Post
    Traq - one set is for background-color and the other is for color

    Cheers

    GW
    whops - missed that! but glad I could help anyway.

Bookmarks

Posting Permissions

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