简体   繁体   English

选择框的文本对齐中心在iPhone上不起作用

[英]Text align center of select-box is not working on iPhone

Text align center of select-box is not working on iPhone. 选择框的文本对齐中心在iPhone上不起作用。 Please help me out. 请帮帮我。

It is working on all devices without iPhone. 它适用于所有没有iPhone的设备。

<style>.demo select {text-align:center;text-align:-moz-center;text-align:-webkit-center;width:200px;}</style>

<div class="demo">
<select>
    <option>demo</option>
    <option>demo</option>
    <option>demo</option>
    <option>demo</option>
    <option>demo</option>
</select>

With the little code that you provided, these are the possible problems: 使用您提供的少量代码,可能会出现以下问题:

  1. You do not need to add vendor prefix for text-align, it is supported by all the browsers, although you are doing it wrong anyway. 您无需添加供应商前缀来进行文本对齐,尽管所有操作都做错了,但所有浏览器均支持该前缀。 Vendor prefixes come before the CSS property not before the value, like so: 供应商前缀位于CSS属性之前,而不位于值之前,如下所示:

    -webkit-border-radius: 2px; -webkit-border-radius:2px;

  2. Based on the code you provided you did not close the div tag. 根据您提供的代码,您没有关闭div标签。

  3. The text-align property specifies the horizontal alignment of text in an element. text-align属性指定元素中文本的水平对齐方式。 Which in your case the parent element is the div.demo. 在您的情况下,父元素是div.demo。 If you want the select element to be centered within the div, your div needs to have some specified width. 如果你想选择元素到div内的中心,你的DIV需要有一些指定的宽度。 For example: 例如:

    div.demo{ width: 500px; div.demo {width:500px; margin: 0 auto; 保证金:0自动; /* If you want it to be centered within its own parent*/ } / *如果您希望它位于其自己的父对象中居中* /}

That is all I can suggest based on your little code! 这就是我根据您的小代码所建议的一切!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM