Home > Article > Web Front-end > Several ways to vertically center css_html/css_WEB-ITnose
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)/