视差滚动(使用JavaScript)问题

视差滚动(使用JavaScript)问题,javascript,twitter-bootstrap,Javascript,Twitter Bootstrap,我正在尝试使用JavaScript和引导程序使用视差滚动。它正在工作,但页脚也随着可滚动的内容移动,我希望页脚应该固定在底部 <?php require 'header.php'; ?> <style type="text/css"> *{ margin: 0px; padding: 0px; } #image { position: relative; z-index: -1

我正在尝试使用JavaScript和引导程序使用视差滚动。它正在工作,但页脚也随着可滚动的内容移动,我希望页脚应该固定在底部

<?php
require 'header.php';
?>

<style type="text/css">
    *{
        margin: 0px;
        padding: 0px;
    }
    #image {
        position: relative;
        z-index: -1
    }

    #content {
        position: relative;
        z-index: 1;
        height: 750px;
        width: 100%;
        background-color:  #4dbbac;
        margin-bottom: 30px
    }

</style>



<script type="text/javascript">  

       var yPos, image;
       function parallax (){
           yPos = window.pageYOffset;
           image = document.getElementById('image');
           image.style.top = yPos * 1 + 'px';
       }
       window.addEventListener('scroll', parallax);  

</script>


<img id="image"  src="../images/company_img1.jpg" height="700px" width="100%" alt="companyProfile_image" class="img-responsive"/>

<div id="content"></div>


<?php
require 'footer.php';
?>

*{
边际:0px;
填充:0px;
}
#形象{
位置:相对位置;
z指数:-1
}
#内容{
位置:相对位置;
z指数:1;
高度:750px;
宽度:100%;
背景色:#4dbac;
边际下限:30px
}
var-yPos,图像;
函数视差(){
yPos=window.pageYOffset;
image=document.getElementById('image');
image.style.top=yPos*1+'px';
}
窗口。addEventListener(“滚动”,视差);

您应该在图像周围添加一个包含css属性的换行div,如下所示

HTML

<div class="container">
  <img id="image" src="../images/company_img1.jpg" height="700px" width="100%" alt="companyProfile_image" class="img-responsive" />
</div>

这样,图像在移动时不会影响DOM的其余部分。

感谢@sankorati的回答。页脚没有移动,但在内容的背景中添加了一个白色层,因此当我使内容透明时,我无法看到图像。这不是背景效果,只是图像由于溢出:隐藏效果而移出了视图。如果将#内容移动到容器内,当其背景色为透明时,内容应重叠。
.container {
    position: relative;
    z-index: 1;
    overflow: hidden;
}