0

General structure of my LESS is like:

div {
  table { .. }
}

div {
  table & { .. }
}

Wanting to know the CSS-only solution using LESS here. I have:

<div>
  <table></table>
</div>

And I want to do something like:

div {
  & > table:empty { display: none; }
}

But completely opposite of what this is doing and instead of affecting the table here, it affects the div. Of course this is just an example since this is saying hide table if empty whereas I want to say hide div if child table is empty. I want a LESS version that will hide the div. Due to padding and a border the div is visible even when the child table is empty.

Thinking about it I think the answer will be no because LESS compiles to actual CSS and since there is no way to accomplish this in CSS, I'm assuming there's no way in LESS either. It just doesn't hurt to ask.

o_O
  • 4,862
  • 11
  • 46
  • 84
  • 1
    related: http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector?rq=1 – cocoa Nov 20 '15 at 21:12

1 Answers1

1

You're right - there is no parent selector in CSS, and therefore LESS - meaning, you can't style an element's parent based on a selector for the element itself. I would look for a solution using whatever script framework or backend framework you have that's building your markup.

inorganik
  • 21,174
  • 17
  • 78
  • 101