How to use display:table-cell to achieve vertical centering?

不言
Release: 2018-10-24 15:26:25
Original
5049 people have browsed it

In web page layout, we often need to vertically center pictures or text. There are many ways to achieve vertical centering. Today I will introduce to you how to achieve vertical centering using the display:table-cell attribute. Let’s look at it below. See the specific content.

First of all, let’s take a brief look atdisplay:table-cell attribute

display:table-cell attribute means that the label element is presented in the form of a table cell, similar to td tag, use display:table-cell to vertically center elements with non-fixed sizes.

Next let’s look at a specific example of display:table-cell achieving vertical centering:

    Document  

php中文网在线免费教程

Copy after login

display:table-cell achieves vertical centering as follows:

How to use display:table-cell to achieve vertical centering?

Note: 1. IE6/7 does not support the display:table-cell attribute; 2. table-cell does not support the margin attribute (but supports padding), which is very rigid; 3. Try not to use it with floating/positioning at the same time, as it will destroy its css properties.

The above is the entire content of this article. For more knowledge about the display:table-cell attribute, you can refer to the php Chinese websitecss Learning Manual.

The above is the detailed content of How to use display:table-cell to achieve vertical centering?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!