0

Currently i am trying to animate a div. I want to try and start the div using the :checked pseudo. I don't want the div I am transforming to be right next to the checkbox(for aesthetic reasons). So I currently have two div's that I am using. One for the checkbox and the other as a stage to play div's I want to animate/transform.

I know you can select elements that are below another element as long as they are the child of the same element using, div + div{}.

But I am wondering if there is another way to select any element after a pseudo element goes into affect on another element(that is not in the same parent)?

Pure CSS or SCSS if their is a way. I know with Jquery I can easily do what I want but I want to stay away from JS for now, if there is another way.

Well I guess I'll after wait for the WD for :has() to come through.

STOAM
  • 95
  • 6
  • 1
    no there is no way (duplicate : https://stackoverflow.com/q/1014861/8620333) – Temani Afif May 31 '19 at 11:53
  • @TemaniAfif is there any sort of proposal for this to happen? Because it seems like a thing that should be possible and not restricted to before and after elements. – STOAM May 31 '19 at 11:55
  • we still need to wait, here is https://drafts.csswg.org/selectors-4/#relational – Temani Afif May 31 '19 at 11:56
  • Possible duplicate of [Is there a CSS parent selector?](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Juan Mendes May 31 '19 at 11:58
  • @TemaniAfif Thanks. At least it's in the pipeline. I guess I'll just have to wait a couple years to do what I want without JS. – STOAM May 31 '19 at 11:58
  • @JuanMendes similar but that post was about selecting the parent of the current element and I want to select an element with a completely different parent. – STOAM May 31 '19 at 12:01
  • Same idea, you traverse down, not up. The performance implications of searching both ways could make this a crippling feature, that's one of the reasons it was never added. – Juan Mendes May 31 '19 at 12:01
  • @JuanMendes Not really. He has a link which is a child of the list element. He is trying to access the parent of the link. I have a title div, with a form and input field, and a stage div with a child box div. The input is a child of the title div and the box is a child of the stage div. Thus it's not really traversing down rather than up, but out and then down and then back in. – STOAM May 31 '19 at 12:07
  • @JuanMendes I guess that is the case. Sad days. Oh well back to JS/JQuery. – STOAM May 31 '19 at 12:10
  • @STOAM it's the same thing. the *parent selector* is the missing piece of puzzle here. Selecting the parent element of a particular child will make you go up in the dom to select another element down again – Temani Afif May 31 '19 at 12:15
  • @STOAM `it's not really traversing down rather than up, but out and then down and then back in`, are these alternative facts? :p you're just saying out instead of up. The DOM is not 3D – Juan Mendes May 31 '19 at 13:16
  • @JuanMendes I guess. I just think 3 dimensionaly. Technically it's up then down and then down again if you were going from element within a parent to an element in another parent. I just think of it kind of differently. – STOAM Jun 02 '19 at 04:14

0 Answers0