美文网首页
如何设置select和option的文字居中?

如何设置select和option的文字居中?

作者: 泰格先森 | 来源:发表于2018-01-11 15:46 被阅读0次

        今天在设置option文字居中时发现,给select设置text-align:center在火狐浏览器下ok,但是在chrome浏览器无效,然后option在两个浏览器下设置text-align:center都是无效的,解决方法,设置样式如下 

select:{   

 width: auto;  

  padding: 0 2%;    

  margin: 0;

}

option{    

text-align:center;

}

1.必须设置select的padding,留意:padding: 0 2%; 前面的0表示上下,后面的值表示左右,这个值设置为1%都可以,但是不能是0,值越大,select就越长。

2.不要设置select的宽(width),auto就可以了。

相关文章

网友评论

      本文标题:如何设置select和option的文字居中?

      本文链接:https://www.haomeiwen.com/subject/cuftoxtx.html