0

I am trying to set a nested set of list items in a Joomla menu so that the outermost parents move down to make room for the children. The height of the list items also needs to be a set height because the menu items are buttons. At the moment what happens is that the parent items below a child item horizontally get pushed into the space of the child item so that they overlap. Here is a simplified example of what I am trying to achieve:

<ul>
     <li style="height: 40px;">Parent Item 1
     <ul>
          <li style="height: 40px;">Child item of 1</li>
     </ul>
     </li>
     <li style="height: 40px;">Parent Item 1</li>
</ul>

Here is a link to a page on my site showing exactly this situation:

http://procadsys.worldnz.co.nz/test

Is there any way with CSS to have the heights properly calculated down this list so that each level is 40 pixels below the previous one without any levels overlapping? I've tried changing the position attribute to fixed and relative as well, but this didn't work.

4
  • 1
    can you add a fiddle or illustrate more or add a screeshot of problam Commented Oct 17, 2012 at 5:56
  • I just edited my post adding a link to a page showing what is happening: procadsys.worldnz.co.nz/test Commented Oct 17, 2012 at 7:03
  • just remove heights from everywhere ? Its impossible to understand you really, even if you need to have buttons, its not A MUST to have heights Commented Oct 17, 2012 at 7:25
  • Yes, I know I can remove heights, but my client wants the buttons to be a particular height. If this is not possible with CSS then I will have to try another way like JS or whatever, but surely something like this can be done with CSS. Commented Oct 17, 2012 at 8:04

2 Answers 2

3

The answer is to use line-height, not height:

<ul>
     <li style="line-height: 40px;">Parent Item 1
     <ul>
          <li style="line-height: 40px;">Child item of 1</li>
     </ul>
     </li>
     <li style="line-height: 40px;">Parent Item 1</li>
</ul>
Sign up to request clarification or add additional context in comments.

Comments

0

You use this style code

ul > li:hover ul{
  height:40px;
  margin:0;
  padding:0;
}

1 Comment

I just tried this, but it did not work. Besides which I do not want the list to expand on mouse-over. I want to see the whole list without part of it overlapping. I'll try to add a screen-shot of the problem now to show the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.