Hello dev.to community!
Thankful for you! Articles are very helpful. Learning so much!
Trying to leverage CSS's "live-ness" (rather than JS poling) to detect the presence of a dynamically loaded child selector to change it's parent's sibling's width per the below scenario and CSS.
Problem is that the CSS relational pseudo-class ":has" is not supported by any browsers yet.
Would CSS variables or a pre-processor be able to handle the below scenario? Not used them yet.
Probably making this too complicated. Open to more efficient ways/techniques.
Any assistance is much appreciated.
Thanks again for all that you do for our community!
Scenario : :
Classic left to right master-detail, holy grail layout, using Bootstrap/Flexbox.
- End-user clicks a list item in
.results
. - Dynamic content is loaded into
.details
. -
.loaded
class is loaded LAST into.details
. - The "Open State" CSS rule becomes TRUE.
-
.details
slides in from the right. - End-user clicks "X" to close
.details
. -
.loaded
is removed from.details
. - The "Open State" CSS rule becomes FALSE.
-
.details
reverts to it's "Closed State" (default). -
.details
slides out to the right.
Hope that makes sense...
CSS : :
/* Closed State (default) */
.results {
flex: 0 0 auto;
width: 0;
transition: width 550ms ease;
}
/* Open State */
.details .loaded {
.results {
width: 25%;
}
}
HTML : :
<div class="results">
<div class="list-of-results"></div>
</div>
<div class="details">
<div class="dynamically-loaded-content **loaded**">
</div>
</div>
'
( ON SCRN ) ' ( OFF SCRN )
' _[ close btn ]
_____ ________.results________'__.details__/
| | | x|
| | | | When the child class
| | | + .loaded | '.loaded' is present in
| | <-|--- | '.details', '.details' slides
| | | | on screen from right
| | | |
| | | |
| | | - .loaded | When '.loaded' disappears
| | --|--> | '.details' slides off screen
| | | |
----- ------------------------ ------------
Top comments (0)