Align text, text box, button vertical center

Source: Internet
Author: User

Key: The text should be included in the label Label and set the line height. Otherwise, the text will match the top of the text box

End alignment. Set vertical-align: middle in the text box; otherwise

Qi. The text in the button is vertically centered. You must set the height to the line height, and the line height to be smaller than the height.

<HTML>
<Head>
<Style type = 'text/CSS '>
Label
{
Line-Height: 20px;
Height: 20px
}
. Button
{
Font-size: 12px;
Text-align: center;
Padding: 0px;
Vertical-align: middle;
Line-Height: 22px;
Margin: 0px;
Height: 26px;
Width: 60px;
}
. Txt
{
Border: 1px # 6699cc solid;
Height: 20px;
Width: 160px;
Margin: 0px;
Vertical-align: middle;
Font-size: 12px;
Padding: 0px 2px;
Line-Height: 16px;
}

</Style>
</Head>
<Body>
Div text, text box, button vertical center Alignment Method and CSS style.
<Div class = "divpad" style = "font-size: 12px; Height: 28px;">

<Label> query: company name </label> <input id = "txt_company"

Type = "text" class = "TXT"/>

& Nbsp; <label> name </label> <input id = "txt_name"

Class = "TXT" width = "80px" type = "text"/>

& Nbsp; <input type = "button" id = "button1" value = "Search"

Class = "button"/> </div>

</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.