Option and Select elements in iOS have unique font sizes

I noticed that the font size of my option is different from my select in Chrome PC compared to IOS. The sizes are exaggerated in the snippet provided. I experimented with and without using optgroup.

.styled-select { overflow: hidden; height: 74px; float: left; width: 365px; margin-right: 10px; background: url(http://i50.tinypic.com/9ldb8j.png) no-repeat right center #5c5c5c; }
.styled-select select { font-size: 34px; border-radius: 0; border: none; background: transparent; width: 380px; overflow: hidden; padding-top: 15px; height: 70px; text-indent: 10px; color: #ffffff; -webkit-appearance: none;
}
.styled-select optgroup { font-size: 14px; }
.styled-select option.service-small { font-size: 14px; padding: 5px; background: #5c5c5c; }
<div class="styled-select slate">
  <select class="service-area" name="service-area">
    <optgroup>
      <option selected="selected" class="service-small">Service area?</option>
      <option class="service-small">Volunteering</option>
      <option class="service-small">Partnership &amp; Support</option>
      <option class="service-small">Business Services</option>
    </optgroup>
  </select>
</div>

Answer №1

This serves as an illustration:

However, in this specific scenario, I am incorporating jQuery as well. This method is effective on IOS.

Reference: link

$('select').each(function () {

    // Cache the number of options
    var $this = $(this),
        numberOfOptions = $(this).children('option').length;

    // Hides the select element
    $this.addClass('s-hidden');

    // Wrap the select element in a div
    $this.wrap('<div class="select"></div>');

    // Insert a styled div to sit over the top of the hidden select element
    $this.after('<div class="styledSelect"></div>');

    // Cache the styled div
    var $styledSelect = $this.next('div.styledSelect');

    // Show the first select option in the styled div
    $styledSelect.text($this.children('option').eq(0).text());

    // Insert an unordered list after the styled div and also cache the list
    var $list = $('<ul />', {
         'class': 'options'
     }).insertAfter($styledSelect);

     // Insert a list item into the unordered list for each select option
     for (var i = 0; i < numberOfOptions; i++) {
         $('<li />', {
             text: $this.children('option').eq(i).text(),
             rel: $this.children('option').eq(i).val()
         }).appendTo($list);
     }

     // Cache the list items
     var $listItems = $list.children('li');
    
     // Show the unordered list when the styled div is clicked (also hides it if the div is clicked again)
     $styledSelect.click(function (e) {
         e.stopPropagation();
         $('div.styledSelect.active').each(function () {
             $(this).removeClass('active').next('ul.options').hide();
         });
         $(this).toggleClass('active').next('ul.options').toggle();
     });

     // Hides the unordered list when a list item is clicked and updates the styled div to show the selected list item
     // Updates the select element to have the value of the equivalent option
     $listItems.click(function (e) {
         e.stopPropagation();
         $styledSelect.text($(this).text()).removeClass('active');
         $this.val($(this).attr('rel'));
         $list.hide();
         /* alert($this.val()); Uncomment this for demonstration! */
     });

     // Hides the unordered list when clicking outside of it
     $(document).click(function () {
         $styledSelect.removeClass('active');
         $list.hide();
     });

 });
body {
     padding:50px;
     background-color:white;
 }
 .s-hidden {
     visibility:hidden;
     padding-right:10px;
 }
 .select {
     cursor:pointer;
     display:inline-block;
     position:relative;
     font:normal 11px/22px Arial, Sans-Serif;
     color:black;
     border:1px solid #ccc;
   width: 450px;
    padding:20px;
 }
 .styledSelect {
   font-size: 30px;
     position:absolute;
     top:0;
     right:0;
     bottom:0;
     left:0;
     background-color:white;
     padding:20px;
     font-weight:bold;
 }
 .styledSelect:after {
     content:"";
     width:0;
     height:0;
     border:5px solid transparent;
     border-color:black transparent transparent transparent;
     position:absolute;
     top:30px;
     right:6px;
 }
 .styledSelect:active, .styledSelect.active {
     background-color:#eee;
 }
 .options {
     display:none;
     position:absolute;
     top:100%;
     right:0;
     left:0;
     z-index:999;
     margin:0 0;
     padding:0 0;
     list-style:none;
     border:1px solid #ccc;
     background-color:white;
     -webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
     -moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
     box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
 }
 .options li {
     padding:0 6px;
     margin:0 0;
     padding:0 10px;
 }
 .options li:hover {
     background-color:#39f;
     color:white;
 }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<div class="styled-select slate">
  <select class="service-area" name="service-area">

      <option selected="selected" class="service-small">Service area?</option>
      <option class="service-small">Volunteering</option>
      <option class="service-small">Partnership &amp; Support</option>
      <option class="service-small">Business Services</option>

  </select>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing a password toggle feature on a form that extends Django's default Authentication Form

Incorporating a password toggle feature has become quite the challenge as I extend Django's AuthenticationForm to create my UserLoginForm. Attempting to implement this feature has proven difficult, especially since I have been unable to make use of th ...

The static background and fixed header are locked in a perpetual battle

I am currently working on creating a fixed header that remains at the top of the page. However, I am facing an issue where the background seems to be overlapping and hiding the header. <style type="text/css> html, body {height:100%; margin:0; paddin ...

RShiny encountering issues while trying to load external HTML file along with CSS file

I've been working on a Shiny app, where I put together the UI code using HTML, CSS, and JavaScript within the www sub-folder, while keeping the app.R file in the main folder. The code in my app is structured as follows: runApp( shinyApp( ui = sh ...

Revive the design of a website

As I work on creating my own homepage, I came across someone else's page that I really liked. I decided to download the page source and open it locally in my browser. However, I noticed that while the contents were all there, the style (frames, positi ...

In the world of web design, blank areas can sometimes appear on a page as you

My website has a fixed header with a height of 44 pixels, content that takes up 89% of the screen, and a footer that occupies 6% of the space. Everything looks fine when the browser is at 100% zoom, but as I zoom out, white spaces start appearing before th ...

Identify the specific element using a designated data attribute

Having trouble figuring out how to select a specific element with a particular data attribute. In my situation, I want to target the a element with class="zoom-image" and data-order-item-id="<?=$order_item_id ?>". Here is the HTML/PHP code snippet ( ...

Discover a personalized message and alter its hue using JavaScript and CSS styling

I've hit a roadblock while creating my website with WordPress and a custom theme. Although I can easily inject custom Js or CSS, I need advice on how to achieve the following: How can I locate the symbol ★ within the content and change its color? ...

There seems to be an issue with the zebra striping in the rich:datatable component when using the rowClasses

I'm attempting to give my table a "zebra" color pattern for the rows, but it seems like the rowClasses attribute isn't functioning properly (edit: I don't see any colors applied to the table at all). Here is how I defined the styles: <s ...

Choosing a root element in a hierarchy without affecting the chosen style of a child

I am working on a MUI TreeView component that includes Categories as parents and Articles as children. Whenever I select a child item, it gets styled with a "selected" status. However, when I click on a parent item, the previously selected child loses its ...

Step-by-step guide on implementing a fade effect to a specific JavaScript element ID

When I click a button, the image on the screen disappears. I am looking to add a fade effect to this action. Can someone help me achieve this using CSS? #hide{-webkit-transition: all 1s ease-in-out;} For reference, here is a demo showcasing the current b ...

What is the reason that the selected/checked attributes of child select and input elements are not preserved when transferring HTML from one element to another?

In the world of jQuery, there lies a curious phenomenon. When you dare to set the HTML of one element as the HTML of another element, a strange omission occurs. The checked attribute of checkbox inputs and the selected attribute of select inputs are myster ...

Mobile devices seem to be constantly refreshing website images

I have a landing page consisting of multiple sections with images as the background, each section occupying the full screen. In one specific section, the images change every 5 seconds. The website works smoothly on desktop, but I encounter issues on mobil ...

Guide to displaying API data in HTML format

This university assignment involves working on a homework project where I need to utilize a public API in HTML. So far, I have successfully called the public API to display a list of radio channels in the left menu (without adding any click functionality). ...

What is the best way to continuously loop the animation in my SVG scene?

After designing a SVG landscape with an animation triggered by clicking the sun, I encountered an issue where the animation only works once. Subsequent clicks do not result in any animation. Below is my current JavaScript code: const sun = document.getEle ...

How to add color to an HTML table depending on 3 different conditions

I have set 3 specific colors in my CSS. I have an HTML table and I am looking to have the background color of a cell change based on 3 conditions: if the cell contains the text 'True' - color green if the cell contains the text 'False& ...

Footnote fiascos

I am currently in the process of creating a footer for my webpage and have implemented the following CSS styling: #footer { height: 100px; background-color: #F3F3F3; position: absolute; bottom: 0; } Although the footer is displaying at th ...

The addition of a cancel swipe feature to an HTML5 eBook is causing the text input field for note-taking to malfunction

I am currently working on the development of a process to create HTML5 based eBooks for both desktop and mobile use using Adobe InDesign and exporting them with a plugin called In5. This plugin allows for the incorporation of html, css, and javascript duri ...

Adding Items to the Beginning of a Drop-down List using jQuery.prepend

I have created a select list for various types of restaurants. Users can choose a food type, click search, and receive a list of restaurants specializing in that particular cuisine. To add an initial option to the select dropdown, I used the following cod ...

What is the best way to synchronize the image dimensions and source when dynamically loading images?

I am facing an issue with a function that updates images by altering the src and css (width/height) of an IMG tag within the document. Below is a simplified example to demonstrate the problem: updateImage = function(src, width, height) { $("#changeMe"). ...

Using AJAX to post button values

I have encountered an issue while attempting to post a value to a PHP script using the POST method in AJAX. The error message is as follows: Notice: Undefined index: gamekey Here is the JavaScript code I am working with: function adminchat(row) { ...