Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 需要固定位置的div来停止页面的一部分_Html_Css - Fatal编程技术网

Html 需要固定位置的div来停止页面的一部分

Html 需要固定位置的div来停止页面的一部分,html,css,Html,Css,我已经创建了一个div并在其上放置了一个图像。目前,图像一直到页面底部,消失在另一个图像后面的一个单独的div中,并完全隐藏页脚div。我需要修复图像并向下滚动页面,但当它到达带有页脚的div时,我需要它停止(在另一个图像后面)。以下是相关代码: CSS HTML &抄袭;版权所有2016。版权所有。欧能公司。 我会附上一些图片。一个是它应该是什么样子,另一个是它当前的样子。 使用CSS3的层属性和z索引,使图像在页面上的div位置更高。使用CSS3的层属性和z索引,使图像在页面上的div位

我已经创建了一个div并在其上放置了一个图像。目前,图像一直到页面底部,消失在另一个图像后面的一个单独的div中,并完全隐藏页脚div。我需要修复图像并向下滚动页面,但当它到达带有页脚的div时,我需要它停止(在另一个图像后面)。以下是相关代码:

CSS

HTML


&抄袭;版权所有2016。版权所有。欧能公司。
我会附上一些图片。一个是它应该是什么样子,另一个是它当前的样子。

使用CSS3的层属性和z索引,使图像在页面上的div位置更高。

使用CSS3的层属性和z索引,使图像在页面上的div位置更高。

padtb30
设置为
显示:相对
,然后将
z索引
设置为100,以说明堆栈高于所有堆栈其他内容

更多信息请点击此处:

padtb30
设置为
display:relative
,然后将
z-index
设置为like 100,告诉它堆叠在所有其他内容之上

更多信息请点击此处:

我将页面的页脚放在另一个名为“bottom”的div中,以实现这一点,我希望页脚保持在页面的底部,而不是在其后面有内容流。然后我将“底部”位置设置为相对。代码如下:

HTML

<div class="bottom">
    <div class="padt120">
        <img src="~/Images/sunwave-about-buildings.png" alt="Sunwave Buildings" class="buildings" />
        <div class="grass"></div>
    </div>

    <footer class="padtb30">
        <span class="copyright">
            <small class="lightgrey-text">
                &copy; Copyright 2016.  All Rights Reserved.  ONEnergy Inc. <a href="http://limeadvertisinginc.com/sunwave-test/public/privacypolicy">Privacy Policy</a>
            </small>
        </span>
    </footer>
</div>

我通过将页面的页脚放在另一个名为“bottom”的div中来实现这一点,我希望页脚保持在页面的底部,而不是后面有内容流。然后我将“底部”位置设置为相对。代码如下:

HTML

<div class="bottom">
    <div class="padt120">
        <img src="~/Images/sunwave-about-buildings.png" alt="Sunwave Buildings" class="buildings" />
        <div class="grass"></div>
    </div>

    <footer class="padtb30">
        <span class="copyright">
            <small class="lightgrey-text">
                &copy; Copyright 2016.  All Rights Reserved.  ONEnergy Inc. <a href="http://limeadvertisinginc.com/sunwave-test/public/privacypolicy">Privacy Policy</a>
            </small>
        </span>
    </footer>
</div>

当我尝试在css Visual Studio中的padtb30下输入display:relative时,会说“relative不是display属性的有效值”,并在其中添加“z-index:xx”,其中xx是一个值,无论我输入了什么值,都不会改变元素的位置。不确定为什么它会说它不是有效值,请自己一直使用它。当然,不在VS:Z中,索引只能在相对或绝对位置下工作。当我尝试在css Visual Studio中的padtb30下输入display:relative时,会说“relative不是display属性的有效值”,并添加“Z-index:xx”其中xx是一个值,无论我输入了什么值,它都不会改变元素的位置。不确定为什么它会说它不是一个有效值,请自己一直使用它。当然,不在VS中:Z索引将仅在相对或绝对定位中工作。我尝试将padtb30的位置设置为绝对,将Z索引设置为多个值,但元素没有移动。我尝试将padtb30的位置设置为绝对,将Z索引设置为多个值,但元素没有移动。
<div class="bottom">
    <div class="padt120">
        <img src="~/Images/sunwave-about-buildings.png" alt="Sunwave Buildings" class="buildings" />
        <div class="grass"></div>
    </div>

    <footer class="padtb30">
        <span class="copyright">
            <small class="lightgrey-text">
                &copy; Copyright 2016.  All Rights Reserved.  ONEnergy Inc. <a href="http://limeadvertisinginc.com/sunwave-test/public/privacypolicy">Privacy Policy</a>
            </small>
        </span>
    </footer>
</div>
.bottom {
    position: relative;
    height: auto;
    width: 100%;
}