固定元素在div的末尾

时间:2016-08-03 09:36:14

标签: javascript jquery html css

我正在搜索很多,但不知道如何正确命名。

点子:

我们有两个div。左边的第一个有很多内容,比右边的内容多。第二个只有填写和发送的形式。当用户滚动左侧div以获取更多信息时,带有联系表单的右侧将跟随此div的末尾。当用户向上滚动时,右侧的这个表单也将跟随它。

如何检测?有没有框架?

我在网站上有很多div,每个人都必须有这个脚本。

屏幕显示我的意思:

SCREEN

链接到页面:

LINK

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

您可以将CSS position: fixed;用于右侧。

答案 2 :(得分:0)

这就是你想要的。这个概念是在您的CSS中使用position:fixedright:0和/或top:10px属性。这是it.hope的一个小例子。这将有所帮助。

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>

<style type="text/css">
	body{
		width: 100%;
		height: 1000px;
		background-color: orange;
	}

.right{
	width: 30%;
	position: fixed;
	right: 0;
	height: 500px;
	background-color: gray;
}

.check{
	position: absolute;
	top: 900px;

}
</style>

<body>

<div class="right">
	<h2>send an email</h2>
</div>

<h1 class="check">checkin the view</h1>
</body>
</html>

值是为了得到一个想法,根据需要改变它们。