0

I wrote text-align=center and tried on desktop browsers and worked successfully but didn't work on mobile browsers (safari and chrome on iPhone).

How to write right css to center text on mobile browsers?

.mobileCss{
    width:50%;
    text-align: center;
}  
<select class="mobileCss">
    <option>aaaaaaaa</option>
    <option>bbbbbbbb</option>
</select>
Matt
  • 14,906
  • 27
  • 99
  • 149
kamal
  • 1,093
  • 6
  • 19
  • 34

2 Answers2

0

Best thing to try is use padding-left on your select.

0

There is no actual way of accomplishing text centering within regular select box in plain CSS. You will have to use javascript/jQuery whether you want or not.

You can:

1) Use a javascript/jQuery plugin to calculate size and center the text everytime it changes value

2) Create a completely custom independent select box

Leo Napoleon
  • 969
  • 6
  • 11