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

Several ways to vertically center css_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:42:131092browse

 

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)/















Statement:
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