I am trying to find a way to limit the width of a <ul>
tag within a dropdown menu in CSS to match the width of its parent <li>
element without setting a fixed width. Despite my efforts, I have not been successful in achieving this and I am seeking help to better understand how it can be done.
Is there a specific property that can make this possible?
I have created a simple jsfiddle example http://jsfiddle.net/zAXRK/2/ to demonstrate the issue. Can someone explain if and how this can be achieved?
Currently, when hovering over the "First Item," the sub-menu appears causing the containing <li>
element to expand and push other elements aside.
My goal is to have the sub-menu always match the width of its parent element dynamically, without fixing it. If a solution cannot be found in CSS, I am willing to use JavaScript as a last resort, but prefer a clean CSS solution as an exercise.
Thank you to anyone who can provide insight into CSS rules. If the answer is out there and I have missed it or misunderstood it, please forgive me.