Common techniques for vertical text Center

Source: Internet
Author: User

1. When the line text is vertically centered

Set the height to equal to the row height.

For example:

<Ul>
<Li> <a href = "#" Title = "nav1" target = "_ Self"> nav1 </a> <li>
<Li> <a href = "#" Title = "nav2" target = "_ Self"> nav2 </a> </LI>
<Li> <a href = "#" Title = "nav3" target = "_ Self"> nav3 </a> </LI>
</Ul>

Set the Row Height and height of a to be equal.

 

2. Vertical center of multi-line text

<Div style = "padding: 10px 0;"> the content of the new Div label is displayed here </div>

Set the filling to be equal to upper and lower.

 

3. Vertical center of input text

<Style type = "text/CSS">
. Bg {
Background: URL (images/search_bg.gif) No-Repeat;
Font-size: 12px;
Padding: 8px 0;
Border: none;
Line-Height: 29px;
Color: # CCC;
_ Height: 29px;
_ Padding: 0;
}
</Style>

<Input name = "Search" type = "text" class = "BG" value = "Enter your keyword" size = "100"/>

Set the line height to the sum of the upper and lower fills and the text size. To be compatible with IE6, define the height for IE6 separately and remove the fill value.

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.