Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OPTION element inside SELECT too long & breaking mobile layout

I have a responsive site design, most of which works just fine.

On the checkout page though I have a Select element for selected a country. Some of the options are very long, the "Congo, the Democratic Republic of the" for example. This pushes the layout out to the right, breaking the layout and making the layout scroll horizontal - which is horrible ;)

If I remove the select completely, the layout displays fine. And if I remove all the options and put short tests ones in their place it also works fine. So I'm pretty sure its the long Option's which is the issue. The Select itself is only 50% wide, so that doesn't run off the screen - its the 'invisible' option elements.

Here is a temp link: http://moymadethis.com/oca/test.html

Works fine on desktop, issue is on iphone mobile (safari, chrome and opera).

Thanks, hope someone can shed some light on a solution for this? Steve

like image 553
user1406440 Avatar asked Jan 21 '26 02:01

user1406440


1 Answers

Normally it suffices to set width on the select element itself (as opposite to setting width on its parent – the inner element will by default overflow if needed), e.g.

 select { width: 6em; }

When the menu is opened (when the element is focused), the options will then appear in a width required by their context, but this will appear in a “layer” on top of the page content, so it should not disturb layout.

If problems remain, please post minimal HTML and CSS code to reproduce the problem and identify the platform(s) and browser(s) tested.

like image 119
Jukka K. Korpela Avatar answered Jan 23 '26 19:01

Jukka K. Korpela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!