Home >Web Front-end >HTML Tutorial >Looking for input and button alignment tips_html/css_WEB-ITnose

Looking for input and button alignment tips_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:12:461204browse

Asking for input and button alignment tips

<!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>


Reply to discussion (solution)

Avoid using For the button element, use input type="button" instead.

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

You can write styles, just define the width and height of the input.

Set a unified style

font-family:Arial,sans-serif,Tahoma; /*Specify the same font*/
font-size:12px; / *Specify the same font size*/
height:25px; /*Solve the height problem in Safari and Chrome*/
line-height:15px; /*Coordinate height to center the text*/
overflow: visible; /*Padding can only take effect under IE if this attribute is set*/
padding:0 0.5em; /*Default values ​​of chrome and ff; adjust their values ​​to make IE the same as other browsers*/

Add

input,button{ vertical-align:middle} 
and try

Just set it to center

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