0

I have a use case, where i need to set height and width of a div based on the number of siblings, for suppose of the parent div has 3 divs inside it, then i need to set the child div's width and height as 33%, if it has 2 div's then set the width as 50% and height as 37.5% and if it has one then set the height as 50% and width as 100%. so all these percentages are based on the parent div's width.

Can anyone tell me how to achieve it using css, even if the parent has different set of element types and want to apply this css only for a certain type, i.e. div's.

Asons
  • 84,923
  • 12
  • 110
  • 165
Ramya B
  • 65
  • 6
  • can you tell me how to do it if i want to select only only div types, i know that i will either have 1 child div with some other elements or 2 divs or 3, that means the same above use case, but in addition to div's if i have some other elements how to achieve it – Ramya B Apr 23 '16 at 08:51
  • You use same trick but like this: https://jsfiddle.net/LGSon/s9b4kjp4/3/ – Asons Apr 23 '16 at 18:23

0 Answers0