Capture ul tag under li through JS

No a positioned element has a z-index of auto by default. That means it does not take part in any stacking level apart from its own position in the html. You need to give that element a z-index that suits its task. That’s why your dropdown is obscured by the border.

Usually a drop-down menu needs to be on top of everything so you would give it a high z index assuming it has no positioned ancestors. (The same applies to your h1 heading and its ancestors if they have a z-index applied other than auto).

1 Like

Take away: z-index only applies to positioned elements. A positioned element is anything other than the static value which is the default for all elements.

(Initially, my understanding was flawed). Thank you so much for being patient and guiding through all the doubts.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.