Home > Web Front-end > HTML Tutorial > Several ways to vertically center css_html/css_WEB-ITnose

Several ways to vertically center css_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:42:13
Original
1147 people have browsed it

 

1. For settings that can be processed in one line height:apx; line-height:apx;

2. For a piece of text (Multiple lines will be displayed)
->2.1 If you can set a fixed height
The parent element uses display:table; height: apx; 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 valign characteristics (Inline element) Valid

  ->2.2 If it is a
with an unfixed height Set the same padding-top:apx; padding-bottom:apx;

->2.3 Use csshack to support ie6 vertical centering. Comprehensive consideration of multi-layer nesting of table-cell solutions. div#wrap {
. display:table;
border:1px solid #FF0099;
background-color ;​​​​ Vertical -align:middle;
                     display:table-cell;                                                                                                 
                        _top:-50%; 1)/















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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template