Home  >  Article  >  Web Front-end  >  How to solve the problem of inconsistent cursor size display in the input input box

How to solve the problem of inconsistent cursor size display in the input input box

php中世界最好的语言
php中世界最好的语言Original
2018-01-26 11:00:132913browse

这次给大家带来input输入框中的光标大小显示不一致应该怎么解决,解决input输入框中的光标大小显示不一致的注意事项有哪些,下面就是实战案例,一起来看一下。

input输入框中的光标大小显示不一致
ie7中和chrome的非常明显
先看看问题产生的原因:chrome浏览器对光标高度的设置原则为,当没有内容的时候光标的高度=input的line-height的值,当有内容时,光标从input的顶端到文字的底部。
OK,既然知道了原因,我们就相应才去一些措施。尝试了两种方法去做:。
方法1:将line-height的值设置为跟字体大小一致;如果高度达不到,用padding去撑;
方法2:对chrome不设置line-height,它会自动文字居中,对ie进行hack设置line-height的值以保证文字垂直居中;这里要注意一下,如果在reset的样式文件中有设置line-height等值,请进行line-height的重置,可以用line-height:normal。具体可以看看腾讯好莱坞页面的搜索框。
具体css:

height: 34px; 
font-size: 12px; 
line-height: normal; 
line-height: 34px\9;

相信看了这些案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

相关阅读:

HTML中head头结构应该如何使用

HTML的head头标签有哪些用法

怎样利用iframe让自己的网页可以显示天气

The above is the detailed content of How to solve the problem of inconsistent cursor size display in the input input box. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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