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) "