9. proficient in CSS and HTML design patterns (positioning: Advanced)

Source: Internet
Author: User

This chapter summarizes all Positioning

I. Align left

Center block elements

Invalid inline Element

① Align the content left and assign the text-align: left value to the block element, because the inline element contains the content size.

② Set the size of the left-aligned element magin-left: 0 align it left, use margin-right: auto to block its right alignment, for absolute positioning elements, use left: 0 left alignment, right: auto to prevent it from right alignment

③ To create a left-aligned and stretched element, you can use width: auto, margin-left: 0, margin-right: 0 to stretch its width to the left and right. For an absolute element, you can use left: 0 and right: 0 to stretch it to the left and right sides.

④ Create a left-aligned package element left: 0 or margin-left: 0

Note: IE6 does not support stretching.

2. Left offset

Margin-left: positive value offset to the right negative value offset to the left

3. Right alignment

Align with left

4. Right offset

Offset from the left

5. Center alignment

Content center alignment text-align: center

Center-aligned left: 0px; right: 0px; margin-left: auto; margin-right: auto


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.