Partial CSS to achieve vertical center and right method

Source: Internet
Author: User
First, vertical centering method:


1 use padding to make multiple text or input centered in Div (for div and text height requirements):


To set the height of the div to one of the highest h1 in each child element, add the div height we need to H2, then we need to populate Padding-top and Padding-bottom are (H2-H1)/ 2, if the selected H1 is not the highest element height, some modules may appear below the


(If the height of the text is unknown and the height of the container is scalable, simply set the padding to fill the container completely for a fixed value)


There is also a multi-text fixed height centering method is to use the CSS display property to make


Simulation, so you can use the Vertical-align:middle. Set the display:table on the parent element, Display:table-cell set on the child element (the method is not valid for the following version IE6)
2 use Line-height to make the line text centered, then set the line-height and height equivalent, then set the Overflow:hidden; (clear float to achieve hidden overflow effect)


Second, make the child elements to the right (not text)


You can use Float:left, but this method affects the relative position of two different child elements under the same parent element when zooming in or out of a Web page


So you can set position:relative on the parent element and then set the position:absolute;left:0px for the child element;
Related Article

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.