Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Daniel1836's avatar

Why does my main screen input box overlap my modal? (z-index?)

I'm using the Select2 plugin for searchable dropdowns.

I had position issue using them inside modals. I found a solution on stack overflow to give the select2 boxes very high z-index. Which worked.

But now I have an issue where if I have a select2 input on my main screen. Then if I open up a modal. The select2 input box from the main screen overlaps the modal.

I tried giving a higher z-index to my modal code. But that didn't work. It is not positioned.

Can anyone help?

Thanks

0 likes
2 replies
Daniel1836's avatar

Here's a screenshot

https://imgur.com/FpM2MYF

The input box that looks out of place never goes out of focus from the main screen. It is in the same spot when I open it.

Any ideas for me? Things to try. Tricks.

JustAnotherCoder222's avatar

Hello Daniel,

this problem has also driven me crazy. I tried playing around with the Z-index for ages but nothing helped. At some point I finally came to the following solution:

$("#yourDropdownObj").select2({ containerCssClass: "yourDropdownObj" }); $(".yourDropdownObj").parent().parent().css("z-index", 500);

That you don't have to change the object itself but the "grandfather"-object is really not so easy to see. I hope it works for you too!

Please or to participate in this conversation.