首页  >  文章  >  web前端  >  求input,button对齐技巧_html/css_WEB-ITnose

求input,button对齐技巧_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 12:12:461173浏览

求input,button对齐技巧

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>button</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">	*{padding:0;margin:0}	body{padding:30px;}	.search{		height:50px;		line-height:50px;		background-color:tan;	}</style></head><body>	<div class="search">		<label>Input your key words</label>		<input type="text" name="hello"/>		<a href="javascript:;"><button>submit</button></a>	</div></body></html>


回复讨论(解决方案)

避免使用button元素吧,用input type="button"代替。

    <div class="search">        <label for="hello">Input your key words</label>        <input type="text" name="hello" id="hello" />        <input type="button" value="submit" />    </div>

可以写样式的嘛,定义一下input的宽高就行了。

设置统一样式

font-family:Arial,sans-serif,Tahoma; /*规定同一字体*/
font-size:12px; /*规定同一字体大小*/
height:25px; /*解决Safari和Chrome下的高度问题*/
line-height:15px; /*协调height,让文字居中*/
overflow:visible; /*只有设置这个属性IE下padding才能生效*/
padding:0 0.5em; /*chrome、ff默认值;调整其值,让IE和其他浏览器的一样*/

加上

input,button{ vertical-align:middle} 
试试

设置成居中就行了呗

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn