Css vertical center:

Source: Internet
Author: User

Css vertical center:

  

1. For rows that can be processed, set height: retrial; line-height: retrial;

 

2. For a paragraph of text (multiple lines are displayed)
-> 2.1 If yes, you can set a fixed height
The parent element uses display: table; height: retrial; The child element uses display: table-cell; vertical-align: middle;

Note: the vertical-align attribute is only valid for some html elements. Specifically, the (X) HTML tag with the valign attribute is used.

For example, is basically effective for inline-block elements (inline elements ).

-> 2.2 If a height is not fixed
Set up the same inner pad-top: retrial; padding-bottom: retrial;

-> 2.3 using csshack to support ie6 vertical center comprehensive consideration of table-cell multi-layer nesting
Div # wrap {
Display: table;
Border: 1px solid # FF0099;
Background-color: # FFCCFF;
Width: 760px;
Height: 400px;
_ Position: relative;
Overflow: hidden;
}

Div # subwrap {
Vertical-align: middle;
Display: table-cell;
_ Position: absolute;
_ Top: 50%;
}

Div # content {
_ Position: relative;
_ Top:-50%;
}

Reference: http://www.zhangxinxu.com/wordpress/2010/05/%E6%88%91%E5%AF%B9css-vertical-align%E7%9A%84%E4%B8%80%E4%BA%9B%E7%90%86%E8%A7%A3%E4%B8%8E%E8% AE %A4%E8%AF%86%EF%BC%88%E4%B8%80%EF%BC%89/

Related Article

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.