Forums

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

Home Forums CSS targeting parent children classes in CSS from a child class

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #236732
    SnowyTerror
    Participant

    Right the topic sounds confusing as hell and I am going to try and explain it in the most basic way possible as basically I was wondering if you had a hover state for a class then you want to change the properties of the parents child class and I want to know if it’s possible. I will give an example of this below. I personally use SASS so I will be showing the format as a SASS method.

    .content
    display: block
    height: 200px
    width: 200px

    .block-1
        color: red
        height: 100px
        width: 50%
        transition: all 0.3s ease-in-out
    
        &:hover
            color: pink
    
    .block-2
        color: blue
        height: 100px
        width: 50%
        transition: all 0.3s ease-in-out
    

    As you see from the SASS code format I want to know if it is possible for when .block-1 is hovered over is it possible for it to then change the properties of .block-2 as .block-2 is not a child of .block-1.

    #236736
    Paulie_D
    Member

    If block-2 is not a child or subsequent sibling of block-1 then there is no CSS method of selecting it.

    You can’t select up the DOM.

    Depending on the actual structure there may options but we’d have to see it.

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