Forums

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

Home Forums CSS Using media queries to detect CSS selector

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #299749
    D7460N
    Participant

    Hey there. Can media queries be used to detect a CSS selector to affect change?

    Example:
    When the .loaded class is dynamically loaded somewhere in the parent “.profile”, the adjacent parent “.results” changes width from 0 to 25%.

    Maybe something like…

    /* Closed State (default) */
    .results {width: 0;}
    /* Open State */
    @media (width = 100% ) { /* Whatever rule that allows the this media query to be true all the time */
         .details .loaded { /* If .loaded class appears in the parent .details */
              .results {
                   width: 25%; /* Change adjacent parent .results to width 25%. */
              }
         }
    }
    

    HTML:

    <div class="results">
         <div class="list-of-results"></div>
    </div>
    <div class="details">
         <div class="dynamically-loaded-content loaded"></div>
    </div>
    
    #299784
    Dainis
    Participant

    +1 for this query – following. thanks

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