1

I have the following structure

<div class='some-group'>
   <div>1</div>
   <div>2</div>
   <div>3</div>
   <div>4</div>   
</div>
<div class='button'>Click</div>

I want that 'button' will be displayed if 'some-group' have more that 2 children and hidden if less that 2. Is this possible using css only?

Alexander Gorelik
  • 3,985
  • 6
  • 37
  • 53
  • No, it is not possible using CSS only. – BenM Apr 20 '17 at 09:23
  • 2
    Not with that HTML structure. If the button could be placed inside the .some-group parent element as well, then it might be possible using what has been dubbed [“Quantity Queries”](https://alistapart.com/article/quantity-queries-for-css) in some way. – CBroe Apr 20 '17 at 09:25

1 Answers1

-2

No, it is not possible by using css only, and I don't think it is the right approach. Any dynamic behaviour should be implemented by javascript, with CSS being purely a style rules container. You are violating the separation of concerns principle from my point of view.

Jacopo Lanzoni
  • 1,264
  • 2
  • 11
  • 25
  • 2
    This is a comment, rather than an answer. – BenM Apr 20 '17 at 09:27
  • Thanks for the feedback, but I think mine is a valid answer. I wrote that it is not possible, and give an alternative option. Please let me know why you think mine is not an answer. – Jacopo Lanzoni Apr 20 '17 at 09:42
  • @JacopoLanzoni it may be an answer now after the edit, as you initially stated 'I don't think'... – BenM Apr 20 '17 at 09:44
  • It would be even better an answer if it actually explained what the JS should do. – Mr Lister Apr 20 '17 at 13:04