Forums

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

Home Forums CSS Use :hover to target another element

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #156858
    rr
    Participant

    Hey guys, I’ve been wondering if it’s possible to make use of :hover state of an input field to target another element. Is that possible?

    I’ve tried to do this but didn’t have any success: http://codepen.io/rafaelrinaldi/pen/twFIC

    Thanks in advance.

    #156859
    singlexyz
    Participant

    you can use the “+” or “~” selector to choose the element after current;

    like this html

    input b b

    input:checked + b will take the element after input when it :checked(just one)

    input:checked ~ b will take all the element after input when it :checked.

    check the demo: http://codepen.io/anon/pen/lywAp

    bad english, hope you can understand.

    #156920
    noahgelman
    Participant

    Pretty much the same as what singlexyz posted expect I edited your original pen. Might be easier to see whats going on.

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

    #156989
    rr
    Participant

    Thanks guys. I was trying to do the exact same thing you guys are suggesting. The problem is that I wanted to target an element that goes before the input I’m listening to. I don’t think that’s possible.

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