一个按钮或链接浮动在网页的一侧

时间:2013-12-26 13:59:17

标签: javascript jquery

我记得有些网站在屏幕的中右/中左侧浮动了一些在线聊天联系我们链接,点击它们会打开带有1或2个输入框和按钮的小表格。

我想实现相同的功能,我不知道他们将这些模块称为什么,以便我可以搜索。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

你需要一个div框才能有绝对位置。通过css

<style>
.sidebox {
    position: absolute;
    width: 200px;
    height: 50px;
}
</style>

<div id="liveChat" class="sidebox"><a href="#">Live Chat</a></div>

最后在JQuery中设置位置

// top left corner
$("#liveChat").css("top", "0");
$("#liveChat").css("left", "0");

// top right corner
$("#liveChat").css("top", "0");
$("#liveChat").css("right", "0");

// bottom right corner
$("#liveChat").css("bottom", "0");
$("#liveChat").css("right", "0");