我有一个 div,我希望它在用户上下滚动时处于固定位置,但我希望它保持左对齐以匹配容器中的所有其他 div。我正在使用 Bootstrap 3 并将我所有的 div 放在一个容器中。当用户上下滚动时,我希望一个 div 保持在一个位置,但是我希望它保持 .container 从 bootstrap 继承的左对齐方式,因此它仍然与网站上的其他所有内容对齐。这是我迄今为止无济于事的。它不遵循 div 的其余对齐方式。
#section {
padding-top: 80px;
padding-bottom: 80px;
z-index: -10;
position: fixed;
left: 10%;
}
<div id="section" class="parallax-section">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12">
<h1>Transformative</h1>
<h1>thinking.</h1>
</div>
</div>
</div>
最佳答案
删除 left:10%
行。
我通过使用 http://codepen.io/pen/ 发现了错误可能是 future css 设计/调试的有用工具。
关于html - 是否可以在滚动时保持 div 位置固定但保持与容器对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38275677/