当我更改窗口的高度时,div孩子的位置不正确 [英] div child does not position right when i change the height on the window

查看:120
本文介绍了当我更改窗口的高度时,div孩子的位置不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将div放置到父div时遇到问题.

当我加载页面时,我将子div放在父div的特定坐标上.

当我的窗口为全尺寸时,此功能有效,但是当我重新使用窗口的尺寸(高度)并重新加载页面时,childDiv在页面上向上移动(错误的位置),它似乎没有粘在我的parentDiv上.

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>





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



当我刷新页面时,如果div上的窗口也向上移动,当我移动底部时,如何避免这种情况?



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?

推荐答案

(" ).css(cssObj);
("#childDiv").css(cssObj);



当我刷新页面时,如果div上的窗口也向上移动时,当我移动底部时,如何避免这种情况?



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?


我不知道这是否是笨拙的/paste错误与否,但是在声明div的ID时有两个引号.

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


第一步是在javascript中调试"top"和"left"变量,因为如果在从底部调整表单大小时div正在移动,我很怀疑那些变量正在更改,但应保持不变.
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.


这篇关于当我更改窗口的高度时,div孩子的位置不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆