treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Hover effect problem

  • I have something of this sort:

    
    ul class="menu"
    li
            (a href="#"(span class="menu-entypo")&#8962(/span)Home(/a)
    /li
    /ul
    

    I want to get the entypo font-icon to turn a color while the home text turns another color on hover over the a link. How do i do that ? Better yet, can i do that? I searched google but i can't seem to find a way to do this and so i thought where else to find an answer then here sooooo here i am. Can anyone help me?

  • EDIT: Hang on I reread your question. You want the regular text and the icon to be different colours?

    That's actually a good one.

    How is the entypo character being loaded right now? Is it done via :before?

    If so you could chain the selector;

      span.menu-entypo:hover:before { color: red; }
    
  • That is exactly what i want. I want the icon and the text to be different colors when i hover the link they are within. So far i load the icon via a span before the home text. I haven't really tried it with :before yet, although i hear this is the best way to use it. The reason i haven't tried it like that is because i thought writing it my way would be easier to actually do what i wanted it to do. I will try your method and i will get back to you as soon as i can. Unfortunately my day job takes a lot of my time. I bet you don't have a lot of accountants members around here :))

  • Hey Kaladan, This might be one way to do it: hover two colors

    li a:hover {
      color: red;
    }
    
    a:hover .menu-entypo {
      color: green;
    }
    

    I tried to solve it without the span - but could not

  • This is excellent. Exactly what i needed. Thanks a lot Magnus_vb. Now that i see it, it seems quite easy but, by God, i wouldn't have come up with this solution to save my life.

  • Yes its possible with

      ul.menu li a:hover {
          color: pink;
       }
       ul.menu li a:hover span.menu-entypo {
           color: red
       }