Valerie Meunier

Valerie Meunier

  • 1.7k
  • 472
  • 21.3k

Question about absolute position of the body

Jun 28 2022 9:17 AM

Hi

I gave the body some styles like this:

<body style="background-color: red; height:1200px; width:800px; position:absolute; left:220px; top:150px">
Then, i put some other elements like:

<asp:Label ID="Label2" runat="server" style="position:absolute; left:394px; top:-124px"  Font-Size="XX-Large" Font-Names="Arial" ></asp:Label>
 <asp:Button ID="Button1" runat="server" Width="80px" style="position:absolute; left:478px; top:-57px; width: 120px;" Text="Hoofdmenu" OnClick="Button1_Click" />

Those elements are on the desired places.

1) the position of the body is absolute with respect to what? I thought the body included everything of the web page.

2) why is the whole page colored and not only the body limited to its height and width?

3) Now i tried this: If i remove position:absolute; left:220px; top:150px from the style of the body, all the elements start in the left upper corner of the page, without taking into account their absolute position with respect to the body. How come?

Thanks

V

 


Answers (3)