CSS - 5t3ph@front-end.social - I'm not sure enough folks realize that :is()/:where(), and :not() can check _ancestor_ and _previous sibling_ conditions.p:is(h2 + *) = paragraphs that are directly after an h2p:not(blockquote *) = paragraphs that are not within blockquotesI've used these techniques to simplify what would otherwise be rather unmaintainable selectors or may have previously required additional conditional classes.https://codepen.io/5t3ph/pen/KKEmMXR
mardi 30 janvier 2024 à 13:36Pas mal cette astuce ! On peut avoir des conditions qui prennent en compte un élément parent ou un élément frère pour cibler un élément...
p:is(h2 + *)
: seulement les paragraphes directement après un H2p:not(blockquote *)
: les paragraphes ne se trouvant pas dans des blockquotes...
Ça peut carrément simplifier certains cas !
<link rel="stylesheet" href="http://www.warriordudimanche.net/./plugins/Galart/style.css"/> <link rel="stylesheet" href="http://www.warriordudimanche.net/./plugins/Galart/assets/lightbox.css"/> <script src="http://www.warriordudimanche.net/./plugins/Galart/assets/lightbox.js"> <script>[].forEach.call(document.querySelectorAll("[lightbox]"), function(el) { el.lightbox = new Lightbox(el);});► Commentaires