Hover one element, change color of another element

Discussion in 'CSS' started by sms4promotion, Aug 26, 2012.

  1. #1
    How can i change color of anchor text inside an li on mouseover of that element?

    code is here


    Any idea plz share.
     
    sms4promotion, Aug 26, 2012 IP
  2. sweetkate

    sweetkate Well-Known Member

    Messages:
    381
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    115
    #2
    You need to code the css part
    some looks like this
    a:hover{color:#666666;
                         background:#fefefe;
    }
    
    
    
    Code (markup):
    the color - is the color of text
    background - is the background-color of that element

    can u please send ur css code here
     
    sweetkate, Aug 26, 2012 IP
  3. sms4promotion

    sms4promotion Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want to set both properties fo li and color for anchor text as well.

    Which you mentioned here is working fine but anchor color is not changing.

    How can i do that?
     
    sms4promotion, Aug 26, 2012 IP
  4. sweetkate

    sweetkate Well-Known Member

    Messages:
    381
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    115
    #4
    please paste here ur css code
     
    sweetkate, Aug 26, 2012 IP
  5. HNC-Web

    HNC-Web Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Although a bit late reply.

    Default CSS:
    li a, li a:visited, li a:active, li a:link{ color:#ff00ff; }
    Code (markup):
    When list item hover is called, change the anchor link color inside the list item:
    li:hover a, li:hover a:visited, li:hover a:active, li:hover a:link{ color:#00ff00; }
    Code (markup):
     
    HNC-Web, Sep 6, 2012 IP
  6. HBz

    HBz Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Let me see if I understand what you're asking here. You want to change the color of a.anchor (the "services" link) on hovering over one of the subnav elements?

    Or, you want to change the color of all the subnav elements on hovering over a.anchor ("services")? If this is the case, that's easy, because the subnav list is inherited from another list. What you should do is assign a class name to the li:

    
    <li class='something'><a class='anchor'></a>
        <ul class='subnav'>
        <li><a>...
        <li><a>...
        </ul>
    </li><!--end li.something-->
    
    Code (markup):
    and do this:

    
    li.something:hover ul.subnav a {
        color: ...
    }
    
    Code (markup):
    On the other hand, if you want to change the hover styles of a parent or unrelated element, you are going to have to use javascript getElementById, or maybe getElementsByClassName, but I'd try to design around such tactics unless it's really critical.
     
    HBz, Sep 24, 2012 IP