HTML Css--position Learning Terminator (ii)

Source: Internet
Author: User

In the blog "HTML css--position learning Terminator (i)" We realize that if the parent of an element of a absolute function (or great-grandfather, as long as the parent object) If the Position property is set and the property value of position is absolute, relative, or fixed, then the child element will refer to the nearest (referring to the child element) and the Position property value is positioned absolute, relative, or fixed parent element, the anchor point of the child element is the upper- left corner of the parent element, People who have studied padding may think this way: if the parent element has the padding style set, then the absolute function's child elements should be positioned from the padding. Oh oh, this kind of understanding right, first see the following example:

Code Listing 01:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" >

Figure

        Description: above son1 parent element does not use padding style, at this time son1 Anchor Point is the upper-left corner of the parent element;

Code 02

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" >

Figure

          Description: above son1 The parent element adds a style Padding-left and sets its value to 50px

        Summary: Compare figure 01 and Figure 02 We will find this case son1 padding-left the influence, according to which we can determine The parent element even if the padding style is set, the absolute action is also positioned from the upper-left corner of the parent element.

        0 Download demo resources "

"See another blog-- HTML Css--position Learning Terminator (i) "

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.