Home Web Front-end JS Tutorial Solution to the problem that the text in the select drop-down list in Safari browser is too long and does not wrap

Solution to the problem that the text in the select drop-down list in Safari browser is too long and does not wrap

Mar 19, 2018 am 10:14 AM
firefox safari webkit

This time I will bring you the Safari browser select drop-down listSolution to the problem that the text is too long and does not wrap. Solve the problem of the Safari browser select drop-down list that the text is too long and does not wrap.NotesWhat are they? Here are actual cases. Let’s take a look.

If the text in the select drop-down list on the web page is too long, it will be automatically truncated in the iOS Safari browser and displayed as follows:

The Android version of the browser does not have this problem.

How to make the text in the drop-down list display completely in the iOS Safari browser? The answer is to use the tag. For information on the role of the optgroup tag, please view the instructions on the w3school website.

The html of the normal select drop-down list is like this:

   请选择车型
   2018款 奥迪A3 30周年年型 Sportback 35 TFSI 进取型2018款 奥迪A3 30周年年型 Limousine 35 TFSI 进取型2018款 奥迪A3 30周年年型 Sportback 35 TFSI 时尚型2018款 奥迪A3 30周年年型 Limousine 35 TFSI 时尚型2018款 奥迪A3 30周年年型 Sportback 35 TFSI 运动型
Copy after login

The html after adding the optgroup tag is like this:

<select id="sel_model" class="form-control">
    <optgroup>
       <option value="">请选择车型</option>
       <option value="5a38a7cae794ff021d4e9eab">2018款 奥迪A3 30周年年型 Sportback 35 TFSI 进取型</option>
       <option value="5a38a7cae794ff021d4e9eac">2018款 奥迪A3 30周年年型 Limousine 35 TFSI 进取型</option>
       <option value="5a38a7cae794ff021d4e9ead">2018款 奥迪A3 30周年年型 Sportback 35 TFSI 时尚型</option>
       <option value="5a38a7cae794ff021d4e9eae">2018款 奥迪A3 30周年年型 Limousine 35 TFSI 时尚型</option>
       <option value="5a38a7cae794ff021d4e9eaf">2018款 奥迪A3 30周年年型 Sportback 35 TFSI 运动型</option>
    </optgroup></select>
Copy after login

Then the display effect on the iOS Safari browser is as follows:

iOS will automatically reduce the font size based on the length of the content in the select drop-down list to ensure that all content can be displayed on one line. Although the optgroup tag is added to the HTML, the method of obtaining the select value through JQuery is not affected in any way. For example, we can still get the selected value of the drop-down list through $('#sel_model').val().

Optgroup is a very magical label!

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to operate unordered list attributes in JS

Detailed discussion of css style initialization

The difference between button and input in the form

The above is the detailed content of Solution to the problem that the text in the select drop-down list in Safari browser is too long and does not wrap. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

8 Ways to Reinstall Safari on iPhone 8 Ways to Reinstall Safari on iPhone Sep 16, 2023 am 11:17 AM

Web browsing is an essential function of mobile devices, and browsers facilitate it effectively. These browsers also support the installation of content blockers and other tools to personalize your browsing experience. Apple's iOS platform uses Safari as its default browser. In rare cases, you may find that Safari browser is missing from your device. If you encounter this situation, the following steps will guide you on how to restore it. Can you reinstall Safari on iPhone? Safari is a built-in application on iOS devices and cannot be deleted or uninstalled due to its protected system status. If the app seems to be missing from your device, you may be dealing with an error, or the app may be hidden for various reasons.

Fix 'Safari cannot open page NSPOSIXErrorDomain:28' error on Mac Fix 'Safari cannot open page NSPOSIXErrorDomain:28' error on Mac Apr 15, 2023 pm 05:34 PM

Since this particular error message may be caused by a bug or some lower-level conflict, it may be sorted out in a future update of Safari or MacOS. Nonetheless, there are some tricks you can apply to fix the problem on your Mac for the time being, or at least fix it. 1: Disable “Hide IP Address” in Safari Many users reported that disabling the IP address hiding feature in Safari and then restarting their Mac solved their problem. Pull down the "Safari" menu and go to "Preferences" Go to the "Privacy" tab Uncheck the "Hide IP address from trackers" checkbox to temporarily disable the feature 2: Disable third-party firewalls, antivirus software, Little Snitch, L

iOS 15: How to switch to private browsing on iPhone using Safari iOS 15: How to switch to private browsing on iPhone using Safari Apr 20, 2023 am 10:55 AM

Safari got an overhaul in iOS 15, and while there are many improvements and changes, some features aren't found where they were before. Read on to learn how to switch to iPhone private browsing in Safari with iOS15. As a refresher, here's how Apple describes Private Browsing Mode: After you close a tab in Private Browsing mode, Safari won't remember the pages you've visited, your search history, or Autofill information. Private Browsing in iOS 15 could be the “Who moved my cheese?” This is a big moment for many users because it’s more private than iOS 14 and earlier — unless you know the shortcut. Except for hiding

How do I do Find (Control+F) in Safari on iPhone and iPad? How do I do Find (Control+F) in Safari on iPhone and iPad? Apr 21, 2023 pm 01:34 PM

How to Use the Control+F Equivalent in Safari on iPhone and iPad Ready to search for matching text on web pages in Safari? Here's all you need to do: If you haven't done so already, open Safari and visit the webpage on which you want to search for matching text Click on the arrow button that comes out of the box in the Safari toolbar Scroll down and click "Find on Page," which is the Control+F equivalent on iPhone and iPad Safari. Enter the text you want to find on the web page. If necessary, use the arrows to navigate to the next or previous instance of the matching text. When finished, tap Done "You go, that's Rong

How to disable private browsing mode in Safari on iPhone How to disable private browsing mode in Safari on iPhone Feb 23, 2024 am 08:34 AM

Apple allows iPhone users to browse anonymously using private tabs on Safari. When "Incognito Mode" is enabled, Safari does not save the addresses of websites you visit, your search history, or Autofill information. If you use private browsing mode frequently in Safari, you may have noticed that the mode operates differently than other browsers. This article will detail how to disable Private Browsing Mode on iPhone and what happens when Private Browsing Mode is enabled when Safari is closed. How to Disable Private Browsing Mode on Safari Required: iPhone running iOS 17 or later. If you have found out how to enable and use private browsing in Safari

Safari zoom issue on iPhone: Here's the fix Safari zoom issue on iPhone: Here's the fix Apr 20, 2024 am 08:08 AM

If you don't have control over the zoom level in Safari, getting things done can be tricky. So if Safari looks zoomed out, that might be a problem for you. Here are a few ways you can fix this minor zoom issue in Safari. 1. Cursor magnification: Select "Display" > "Cursor magnification" in the Safari menu bar. This will make the cursor more visible on the screen, making it easier to control. 2. Move the mouse: This may sound simple, but sometimes just moving the mouse to another location on the screen may automatically return it to normal size. 3. Use Keyboard Shortcuts Fix 1 – Reset Zoom Level You can control the zoom level directly from the Safari browser. Step 1 – When you are in Safari

What does it mean when safari server stops responding? What does it mean when safari server stops responding? Oct 31, 2022 pm 05:19 PM

The safari server stops responding mainly because the iOS device has no network or the network is unstable. The solution: 1. Click the refresh button behind the URL bar; 2. Check whether the Wifi network is available; 3. Turn off Wifi and use the mobile network; 4. , Clear redundant wifi; 5. Reset DNS.

Microsoft: Outlook error downloads 'TokenFactoryIframe' file on every visit Microsoft: Outlook error downloads 'TokenFactoryIframe' file on every visit Apr 19, 2023 am 08:25 AM

Microsoft Outlook is downloading a mysterious file called "TokenFactoryIframe" on macOS when users access the email service through the Safari browser. This issue has now been widely reported by users who have discovered "TokenFactoryIframe" files that Outlook downloads on every visit. Outlook downloads this mysterious file every few seconds or at least every time you access Outlook on Apple platforms. Based on our findings, this appears to be an issue caused by an incorrect server-side update posted to Outlook and has nothing to do with Safari or macOS. Microsoft in a copy

See all articles