使用Cordova与AngularJS开发的iOS应用select字段文本换行问题求助
Hey there, I’ve dealt with this exact iOS-specific styling oddity in Cordova projects before—super frustrating when Android and web behave perfectly! Let’s walk through some actionable fixes:
Tweak CSS for Native Select
iOS Safari (and by extension, Cordova’s WKWebView) has default styling forselectelements that can force text wrapping. Add these styles to target your "Show Everyone" select field:.your-select-class { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; /* Optional: Adds ellipsis if text is too long instead of cutting off */ min-width: 100%; /* Ensures the select takes full width of its container */ }Just replace
.your-select-classwith the actual class or selector for your problematic select.Adjust Cordova WebView Settings
Sometimes the WKWebView’s default viewport or scaling settings throw off element rendering. Update yourconfig.xmlwith these preferences to standardize behavior:<preference name="Viewport" value="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <preference name="WKWebViewOnly" value="true" /> <!-- Ensures you're using the modern WKWebView -->Lean Into Your Alternative Solution: Custom Select Components
If native select styling proves too stubborn (iOS loves to override custom styles!), building a custom dropdown with AngularJS directives (using divs/ul/li) gives you full control over text wrapping and layout. You can bind it to your model just like a native select, and skip all the iOS-native quirks entirely. This is usually my go-to when native selects won’t play nice.Test in iOS Safari First
Before diving into Cordova-specific fixes, load your app’s web version in iOS Safari. If the wrapping happens there too, it’s a pure CSS issue—if not, it’s likely a Cordova WebView configuration tweak you need.
Let me know if any of these get that "Show Everyone" text staying on one line!
内容的提问来源于stack exchange,提问作者MatPonting

