Jquery CSS绝对DIV导致其他绝对DIV问题

Jquery CSS绝对DIV导致其他绝对DIV问题,jquery,css,chat,Jquery,Css,Chat,我已经实现了一个聊天脚本,它要求在页面内容周围包装一个绝对定位的DIV 这是为了确保聊天窗口位于底部 问题是,由于这个主包装器的绝对位置,所有其他绝对位置的元素(例如Jquery Auto completes、datepicker等)现在都随页面上下滚动 以下是HTML的一个示例: <body> <div id="main_container"> <div id="content">Elements like Jquery Autocompletes,

我已经实现了一个聊天脚本,它要求在页面内容周围包装一个绝对定位的DIV

这是为了确保聊天窗口位于底部

问题是,由于这个主包装器的绝对位置,所有其他绝对位置的元素(例如Jquery Auto completes、datepicker等)现在都随页面上下滚动

以下是HTML的一个示例:

<body>
<div id="main_container">
    <div id="content">Elements like Jquery Autocompletes, Datepickers with absolute positioned elements in here</div>
</div>
我希望有一个简单的修复,因为聊天脚本太好了,无法摆脱

谢谢

提姆

  • 您最好将要保留的内容设置在相对于视口的固定位置,位置:fixed
  • 背景色看起来不太好
  • 您可以使sorrounding元素(main)position:relative,而无需为其提供top/left/right/bottom属性以及position:absolute中的每个“固定”元素,因为它们现在将相对于position:relative的父元素
  • 如果这些都不起作用,请发布更多代码,特别是关于“随页面上下滚动的元素”的定位。也不清楚你说的“页面”是什么意思。身体Html?视口?主要内容是什么

  • 好的,我只是把定位改为相对。一切似乎仍在运行,非常好!我需要测试更多的错误,但感谢您的回答!
    #main_container {
        width:100%;
        background-color:#ffffff; /* DO NOT REMOVE THIS; or you'll have issue w/ the scrollbar, when the mouse pointer is on a white space */
        overflow-x: hidden;
        overflow-y: scroll;
        height:100%;    /* this will make sure that the height will extend at the bottom */
        position:absolute; /* container div must be absolute, for our fixed bar to work */
    }