The element in TD treats the first absolute/relative location hierarchy parent as offsetparent. If it is not found, it should be discussed in three cases.
1. If the element is not absolutely/relative located, TD will be treated as offsetparent
2. If the element is absolute/relative located and the table is not absolute/relative located, the body is treated as offsetparent.
3. If the element is absolute/relative and the table is absolute/relative, the table is treated as offsetparent.
Let's take a look at the sample code.
1. <body>
<Table border = 1 align = right>
<Tr>
<TD id = ocell> <Div id = "parentdiv" style = "position: relative "> parentdiv <Div id =" Sondiv "> Sondiv </div> </TD>
</Tr>
</Table>
Running result parentdiv. offsetparent. tagname is "body"
Sondiv. offsetparent. ID is "parentdiv"
2. <body>
<Table border = 1 align = right>
<Tr>
<TD id = ocell> <Div id = "parentdiv" style = "position: relative"> parentdiv <Div id = "Sondiv" style = "position: relative "> Sondiv </div> </TD>
</Tr>
</Table>
Running result parentdiv. offsetparent. tagname is "body"
Sondiv. offsetparent. ID is "parentdiv"
3. <body>
<Table border = 1 align = right>
<Tr>
<TD id = ocell> <Div id = "parentdiv"> parentdiv <Div id = "Sondiv" style = "position: relative "> Sondiv </div> </TD>
</Tr>
</Table>
Running result parentdiv. offsetparent. tagname is "TD"
Sondiv. offsetparent. tagname is "body"
4. <body>
<Table border = 1 align = right>
<Tr>
<TD id = ocell> <Div id = "parentdiv"> parentdiv <Div id = "Sondiv"> Sondiv </div> </TD>
</Tr>
</Table>
Running result parentdiv. offsetparent. tagname is "TD"
Sondiv. offsetparent. tagname is "TD"
5. <body>
<Table border = 1 align = right style = "position: relative">
<Tr>
<TD id = ocell> <Div id = "parentdiv" style = "position: relative"> parentdiv <Div id = "Sondiv" style = "position: relative "> Sondiv </div> </TD>
</Tr>
</Table>
Running result parentdiv. offsetparent. tagname is "table"
Sondiv. offsetparent. tagname is "parentdiv"