CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了css – 绝对div不会滚动页面大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
从下面的小提琴,我试图让’内部导航’div绝对定位,以便它固定在’比较显示’框内.我遇到的问题是,当你滚动时,’内部导航’div不会保持固定.我该如何解决这个问题?

这是我的小提琴:

http://jsfiddle.net/Cd9eZ/

HTML代码

<div class="compare-display">
    <div class="table">
        <div class="source-compare col-50">
            <div class="page"></div>
        </div>
        <div class="navigation-compare">
            <div class="inner-navigation"></div>
        </div>
        <div class="target-compare col-50">
            <div class="page"></div>
        </div>
    </div>
</div>

CSS代码

.table {
    display: table;
    height: 100%;
    width: 100%;
}
.table > div {
    display: table-cell;
    vertical-align: top;
}
.table > .col-50 {
    width: 50%;
    background: green;
}
.compare-display {
    position: relative;
    overflow: auto;
    height: 200px;
}
.compare-display .navigation-compare {
    min-width: 50px;
    background: blue;

}
.compare-display .page {
    margin: 20px;
    height: 500px;
    background: orange;
}
.compare-display .inner-navigation {
    position: absolute;
    width: 50px;
    top: 0;
    bottom: 0;
    background: red;
}

解决方法

认为你想要的位置:固定而不是位置:绝对.

Fiddle

CSS Position Documentation

大佬总结

以上是大佬教程为你收集整理的css – 绝对div不会滚动页面全部内容,希望文章能够帮你解决css – 绝对div不会滚动页面所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: