Self-adapting centering

Source: Internet
Author: User
First, the form is centered

Position:absolute; top:0; right:0; bottom:0; left:0; Margin:auto; /*height:50px; width:165px; */

Brief analysis:

Position: Fixed position display (absolute|fixed);

"Absolute: Window size is determined by upper position for absolute, fixed, relative child-parent relationship window; fixed: The window size is determined by the upper layer position as a fixed child-parent Relationship window"

Top,right,bottom,left: Set offset (<value>|auto);

When set to Auto, indicates that the window is not centered in that direction, such as: Left:auto, the window is not centered in the horizontal position.

Margin: Adaptive layout (auto);

"Window will only center in the direction of auto"

HEIGHT,WIDHT: can be set or not set (<value>|auto);

"No setting is determined by top,right,bottom,left size"

Two, text, picture Mix Adaptive Center

. nav {position:relative;float:left;width:220 px;height:45 px;cursor:pointer;line-height:45 px;text-align:cente R;vertical-align:middle;color: #fff; font-size:18 px;font-weight:600; }.nav.nav-item {position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;height:25 px;line-height:25 Px;di Splay:table-caption; }    . nav span {position:relative;top:0;bottom:0;height:25 px;padding-left:30 px;display:inline-block;}    . nav img {position:absolute;top:0;left:0;width:25 px;height:25 px;z-index:10}

Brief analysis:

. NAV: Limit window size;

"Text-align: Limit span Horizontal Center"

. Nav-item: Control content vertically centered;

"Display: Restrict content side-by"

. Nav Span: Limit picture display range;

"Padding-left: Leave a display space for the picture; display: Fit to show"

. Nav img: Limit image size and display position;

Perfect, just because it's simple.

  • 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.