4 ms·
wtf? Why do I get downvoted? Could the downvoter explain please. Again, insteat of being able to just select a parent on the existence of a child, why not be a
by yaix 15y ago
wtf? Why do I get downvoted? Could the downvoter explain please.
Again, insteat of being able to just select a parent on the existence of a child, why not be able to select any element on the existence of another element? Change the background of a body > div if there is only one child in a list body > ul > li:only-child for example.
body > div /if/ body > ul > li:only-child { background:green; }
Or replace /if/ with :: or $ or whatever.
- masklinn 15y agoI'm not sure you understand what /op/ does. It's a reference indirection going through an IDREF type: * It finds whatever elements are before the operator * It gets the value of the operator's attribute (or type IDREF), ~ storing it in $ID * it combines the selector after it with the root being extended with `[id=$ID]` `/if/` would get the value of the attribute `if` and try to find an element with that value as its id.
- yaix 15y agoAgain, what I care about is not the syntax but the functionality. If you want write it as body > div:if(body > ul > li:only-child) { background:green } body > div:not(body > ul > li:only-child) { background:green } which may or may not already work in CSS3.
- masklinn 15y ago> Again, what I care about is not the syntax but the functionality. Issue here is that you're talking about this using syntax for something which has absolutely no relation. Which is a tad confusing. No, what you want does not work in CSS, you can't make a selector conditional on a second completely unrelated selector (you probably can in XPath, although I'm sure your colleagues will soon look to end your life if you do)
- yaix 15y agoCould you explain why? Let's say you have a clickable element and want to display a status text on hover. The status texts are loaded in some divs somewhere else on the page. You would need JS to catch onhover and then swap the display:hidden to block or whatever. Why would anybody look to "end my life" if that was possible? div.status > span:on(div.clickme > a:hover) { display:block; } Why would that be bad?
- masklinn 15y ago> Why would that be bad? It's "action at a distance", it's very, very hard to understand and debug what happens.
- yaix 15y ago(1) You mean like when you do the same thing with Javascript? Why its okay then? (2) If you alter a parent element with CSS that's "action on a distance" as well. Your argument is not very convincing.