Click here to Skip to main content
15,868,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have a problem with the placement of a div to the parent div.

when i load the page i place the child div on a specific cordinate on the parent div.

this work when my window is in full size but when i reduse the size (height) of the window and reload the page my childDiv is moved up (wrong location) on the page, it doesn't seem to stick on my parentDiv.

<div id="parentDiv">
    <asp:Panel ID="panel" runat="server" Wrap="false">
    <div id="childDiv">
     some contents
    </div>
    </asp:Panel>
</div>


C#
var cssObj = {
    'position': 'absolute',
    'top': top,
    'left': left
}
$("#childDiv").css(cssObj);


edit: when i move the bottom if the window up the div also moves up when i refresh the page, how can i avoid this?
Posted
Updated 5-May-11 3:51am
v6
Comments
#realJSOP 5-May-11 9:52am    
I ficxed your code formatting problem (pre blocks were whacked).

I don't know if this is a coipy/paste error or not, but you have two quotes where you're declaring the div's ID.

<div id=""parentDiv">

It should be:

<div id="parentDiv">
 
Share this answer
 
Comments
CrafterIt 5-May-11 8:48am    
the extra "" happened when i pasted the code between the pre tags, i tried to edit them out. but i missed some it seems.
First step would be to debug your "top" and "left" variables in the javascript because if the div is moving when you resize the form from the bottom, I am suspicious that those variables are changing, but should remain static.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900