浮动层

yanbinquan 2011-02-22 02:08:41
想制作一个浮动层,像http://www.opple-lighting.com/右下角那个send message.
固定在浏览器右下角.
该怎么实现呢?
...全文
62 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
JKelfin 2011-02-22
  • 打赏
  • 举报
回复
<html>
<script>
var imgPanel = document.createElement("img");
imgPanel.src = "http://www.cnblogs.com/images/logo_small.gif";

function FloatDiv(youPanel)
{
this.container = document.createElement("div");
this.container.appendChild(youPanel);
this.innerPanel = youPanel;
this.container.style.position = "fixed";//这个属性会保持你这个container的决定位置
this.container.style.right = "0px";//设置靠右边
//this.container.style.top = "100px";//设置Y轴位置
this.container.style.bottom = "10px";//设置Y轴位置
document.body.appendChild(this.container);
}

function doSomething()
{
//首先添加一些占空间的div
for(var i = 0; i < 100; i++)
{
var split = document.createElement("div");
split.innerHTML = "the " + i +" line";
document.body.appendChild(split);
}

//新建一个浮动div,把你想要放进去的东西给塞进去就好了
new FloatDiv(imgPanel);
}
</script>
<body onload="doSomething()">
</body>
</html>
yuanyue0540 2011-02-22
  • 打赏
  • 举报
回复
浮动广告?

使用div.style和document.body来精确定位

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧