500字范文,内容丰富有趣,生活中的好帮手!
500字范文 > 分享input文字垂直居中和按钮对齐问题的实例教程

分享input文字垂直居中和按钮对齐问题的实例教程

时间:2020-07-28 04:55:14

相关推荐

分享input文字垂直居中和按钮对齐问题的实例教程

web前端|html教程

input,ie,按钮,垂直,文字,中和

web前端-html教程

1、盒子模型问题:请CSS重置

h5小游戏源码抓取,ubuntu自动切换kde,搭环境tomcat有什么用,app爬虫抓包,php长方形周长沙和面积,仁怀seo推广lzw

2、按钮不对齐:请浮动或者vertical-align:middle;然后计算宽高,使其对齐 ;

asp扁平化网站源码,vscode关联文件图标,ubuntu无图像,tomcat部署项目去掉,sqlite3 重新编译,搜索引擎爬虫工作流程,php 转码函数,烟台seo推广软件总部,移动端的网站模板下载安装,微科技h5制作网站模板下载lzw

3、IE8文本不居中:line-height属性注意:IE8不支持font写法(或者某个样式不支持)

网站模板淘宝html源码下载,Ubuntu云打印服务,tomcat是什么意思啊,网络爬虫音乐,php 读写json数据不重复,云南SEO经理lzw

IE浏览器测试到IE8,IE5、6、7慎用。

问题原因:盒子模型

1、盒子模型:

在页面放2个input,一个text文本框,一个button按钮(设置宽高,无任何其他样式)

input[type=’text’]{width:400px;height:45px;}

input[type=’button’]{width:45px;height:45px;}

观察:IE8:文本框border:1px;padding:2px;

按钮border:3px;padding:1px 8px;

火狐:文本框border:1px;padding:2px;

按钮border:3px;padding:0px 8px;

谷歌:文本框border:2px;padding:1px 0px;

按钮border:2px;padding:1px 6px;

添加样式,让border,padding一样

input[type=’text’]{width:400px;height:45px;border:1px solid red;padding:0;}

input[type=’button’]{width:45px;height:45px;border:1px solid red;padding:0;}

观察:

IE8:文本框border:1px;content:202×47 (IE的盒子模型)

按钮border:1px;content:45×45 (IE的盒子模型)

火狐:文本框border:1px;content:200×45

按钮border:1px;content:43×43

谷歌:文本框border:1px;content:200×45

按钮border:1px;content:43×43

2、按钮对齐方法:浮动(原因是Offset不同没有搜索更多的知识,可以自己补充这方面的知识);

input[type=’text’]{width:400px;height:45px;border:1px solid red;padding:0;float:left;}

input[type=’button’]{width:45px;height:45px;border:1px solid red;padding:0;float:left;}

参考第2步,自行计算宽高,使其对齐(有的可能没有border,用的背景色代替,请设置border:0;高度自行调整)

input[type=’text’]{width:400px;height:45px;border:1px solid red;padding:0;float:left;}

input[type=’button’]{width:47px;height:47px;border:1px solid red;padding:0;float:left;}

3、IE8文本居中:line-height注意 IE8不支持font写法

将font:normal 18px “微软雅黑”;换成font-size:18px;font-style:normal;font-family:”微软雅黑”!

或者(这样可以用font:normal 18px “微软雅黑”;写法,但是有点不是在正中间)

input[type=’text’]{width:400px;height:25px;padding:10px 0px;border:1px solid red;float:left;}

input[type=’button’]{width:47px;height:47px;line-height: 47px;border:1px solid red;padding:0;float:left;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。