Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.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,我有一个这样的部门: HTML <div class="row" style="min-height: calc(100vh - 81px);"> <aside class="col-lg-3" style="padding-top: 8px; background: rgb(227, 227, 227); padding-left: 20px;"> <h3>Title</h3> <div id="tr

我有一个这样的部门:

HTML

<div class="row" style="min-height: calc(100vh - 81px);">
    <aside class="col-lg-3" style="padding-top: 8px; background: rgb(227, 227, 227); padding-left: 20px;">
        <h3>Title</h3>
        <div id="treeparent"></div>
    </aside>
    <div class="col-lg-7 pt-2"></div>
    <div class="col-lg-2" style="border-width: 0px 0px 0px 0.25rem; border-style: solid; border-color: rgb(234, 35, 40); border-image: linear-gradient(rgb(179, 108, 219), rgb(235, 73, 113)) 0 0 0 100% / 1 / 0 stretch;">
        <div id="tocOut">
            <div>
                <h1 id="this-is-a-title" class="header-toc">
                    <a href="#this-is-a-title" title="This is a title">
                        <span>This is a title</span>
                    </a>
                </h1>
            </div>
        </div>
    </div>
</div>

问题是
#tocOut
div没有粘在屏幕顶部,我不知道为什么。

元素只有在父元素在视口中并且高于视口时才会被修复

稍微更新一下你的代码

#tocOut{
位置:-webkit粘性;/**/
位置:粘性;
填充顶部:8px;
顶部:21px;
溢出:自动;
背景:橙色;
}


另一内容另一内容另一内容另一内容另一内容另一内容另一内容另一内容另一内容
当然,只有当父元素位于视口中且高于视口时,元素才是固定的

稍微更新一下你的代码

#tocOut{
位置:-webkit粘性;/**/
位置:粘性;
填充顶部:8px;
顶部:21px;
溢出:自动;
背景:橙色;
}


另一内容另一内容另一内容另一内容另一内容另一内容另一内容另一内容另一内容
那么你想停留在底部还是顶部,请简要说明。那么你想停留在底部还是顶部,请简要说明
#tocOut {
    position: sticky;
    padding-top: 8px;
    top: 81px;
    overflow: auto;
    height: 100%;
}