【发布时间】:2016-07-04 15:16:52
【问题描述】:
我想创建一个部分(如 Facebook 上的右侧部分)。固定但从底部开始的部分;就我滚动而言,该部分滚动。但是当我到达该部分的底部时,它会固定并停留在屏幕上。
我认为用纯 CSS 做这个是不可能的,也许是 JS..
您有什么解决方案可以解决这个问题吗?
提前,谢谢。
【问题讨论】:
标签: javascript jquery css scroll fixed
我想创建一个部分(如 Facebook 上的右侧部分)。固定但从底部开始的部分;就我滚动而言,该部分滚动。但是当我到达该部分的底部时,它会固定并停留在屏幕上。
我认为用纯 CSS 做这个是不可能的,也许是 JS..
您有什么解决方案可以解决这个问题吗?
提前,谢谢。
【问题讨论】:
标签: javascript jquery css scroll fixed
使用 bootstrap 将使这更容易。你可以通过navbar-fixed-bottom实现这个目标
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body style="height:1500px">
<nav class="navbar-inverse navbar-fixed-bottom">
<div class="container-fluid">
<h3>Hello<h3>
</div>
</nav>
<div class="container">
<h3>Fixed Navbar</h3>
<div class="row">
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
</div>
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
</div>
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
</div>
</div>
</div>
<h1>Scroll this page to see the effect</h1>
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<div class="col-md-4">
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
<p>A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.</p>
</body>
</html>
【讨论】: