Change the height of the parent of a visible li

Change the height of the parent of a visible li

I use a CSS-Menu with this structure:

  1. <div class="tabs">
  2.     <ul class="menu">
  3.     <li id="item-1">
  4.         <a href="#item-1">Tab 1</a>
  5.         <div><p>
  6. ..
  7. </p></div>
  8.     </li>
  9.     <li id="item-2">
  10.         <a href="#item-2">Tab 2</a>
  11.         <div><p>....</p></div>
  12.     </li>
  13.       </ul>
  14. </div>
Via CSS .tabs will be position:relative and the divs within the li are position:absolute to stack. This works fine.

Unfortunately, in some cases the content of li is too height and overflow the parent. I'm looking for a way to find out the displayed li and this height to apply it on the parent elements (CSS) height.

Is there a way to solve this?