Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Affecting different classes on hover

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #200865
    robguy21
    Participant

    Hi guys, I know this has been answered a lot but not in the way I need it

    I want to make class2 change background color when class1 is hovered. However, class1 and class2 are not related.

    http://codepen.io/anon/pen/MwWWLG

    Please help me out here, I tried to simplify my html structure as much as possible (hence the empty classes).

    #200869
    Paulie_D
    Member

    Basically, you can’t do this with CSS if the elements aren’t related and even if they are related you can’t affect previous siblings or parents.

    You need Javascript or a JS library…then it gets much easier.

    #200870
    robguy21
    Participant

    I’m at this stage where I’m trying to minimise all usage of javascript until there is absolutely no hope.

    What I’m trying to do now is wrap all my content in a <a> tag </a> and change some divs to spans and make those spans act as divs. If it works i’ll post it here.

    I know how easy this is to do if I used JS but where’s the fun in taking the easy way out?

    #200872
    Paulie_D
    Member

    I’m at this stage where I’m trying to minimise all usage of javascript until there is absolutely no hope.

    Then that’s where you are at I’m afraid.

    What I’m trying to do now is wrap all my content in a <a> tag </a>.

    Not sure what you hope to achieve with that..can’t see how that would affect the fundamental fact that, as yet, you can’t select upwards in the DOM.

    #200873
    robguy21
    Participant

    I’m actually getting really close to what I want to achieve.

    Sacrificing a bit but fortunately for the client (who is now officially my guinea pig) the page will function as it should.

    I have now wrapped my a tag around the entire bunch of content and changed a bunch of divs into spans.

    Going to use pseudo elements to change it up.

    #200874
    Paulie_D
    Member

    I have now wrapped my a tag around the entire bunch of content and changed a bunch of divs into spans.

    Doesn’t sound like you’re worried about semantics then. :)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.