Introduction to the usage of Display:table-cell

Source: Internet
Author: User

Introduction to Display:table-cell Usage:
Display properties are used fairly frequently, such as Display:block or display:inline, but may be unfamiliar to Display:table-cell, because this property plays a big role in certain situations, Here is a brief introduction to its role, first look at a code example:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">. Parent{width:600px;Height:600px;Background-color:Green;vertical-align:Middle;}. Children{width:100px;Height:100px;Background-color:Red;}</style></Head><Body><Divclass= "Parent">  <Divclass= "Children"></Div></Div></Body></HTML>

In the above code, although Vertical-align:middle is added to the parent Div, the sub-div cannot be vertically centered. Change the code below:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">. Parent{width:600px;Height:600px;Background-color:Green;Display:Table-cell;vertical-align:Middle;}. Children{width:100px;Height:100px;Background-color:Red;}</style></Head><Body><Divclass= "Parent">  <Divclass= "Children"></Div></Div></Body></HTML>

The above code shows that, after adding Display:table-cell, the sub-div has a vertical centering effect in the parent Div, but it is important to note that the IE6 and IE7 are not valid in the lower version of the browser. This can lead to the role of Display:table-cell, which can specify the object as a table cell, similar to the HTML tag <td>, that is, it can make the object has the properties of the table cell, so in the second instance, the display is added: After the Table-cell attribute, the DIV has the valign attribute, so the vertical-align:middle takes effect.

The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0501/502.html

Introduction to the usage of Display:table-cell

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.