1

I've been reading that there is no such thing in css like a parent selector: https://css-tricks.com/a-use-case-for-a-parent-selector/

Also mentioned here: Is there a CSS parent selector?

However, I don't want to use JS for this use-case and need to apply display:none to the parent element (the child is not enough) - only if the data-path of the child ends with .png:

element to filter

What I've tried:

This works only for the child element (the parent is not even mentioned):

div[data-path$='.png'] {
    display: none;
}

Same thing here as expected:

.nav-file div[data-path$='.png'] {
    display: none;
}

I also tried the has-selector, but it didn't work either:

.nav-file:has(div[data-path$='.png']) {
    display: none;
}

The style has to be applied to the .nav-file-Object and not the child - any ideas?

Used Browser: Electron / Obsidian --> Chromium

Martin Dallinger
  • 369
  • 1
  • 12
  • 3
    Your CSS with the :has works for me on current versions of Edge/Chrome on Windows10. but not all browsers support :has, see https://caniuse.com/?search=%3Ahas – A Haworth Sep 11 '22 at 10:29

0 Answers0