无论页面滚动到何处,如何从页面顶部保留<div> 100像素?

Mic*_*ael 0 html css jquery

我正在建立一个带有<div>框(聊天框)的网站,只要网站所有者决定开始与其中一个访问者进行对话,就会弹出该框.现在的样子,访问者可能在聊天框弹出之前滚动了几页,然后隐藏了聊天框!如何才能使聊天框始终弹出页面的可见区域?

我使用jQuery轮询服务器,并在需要时加载框.

#chatBox {
  z-index: 100;
  position: absolute;
  top: 100;
  left: 200;
  width: 400;
  height: 200;
  background-color: #8596C1;
  padding: 15px;
  border: solid 2px;
  border-color: #BDDEFF #14285F #14285F;
  display: none;
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助 :)

scr*_*agz 7

.chat_container { position: fixed; top: 100px; }
Run Code Online (Sandbox Code Playgroud)


dec*_*eze 5

这可以通过应用position: fixed样式来完成.
但是在IE6中不起作用,如果你足够关心,你需要一个Javascript后备.