【问题标题】:Sass/CSS: Stop fixed div from scrolling along with parent divSass/CSS:阻止固定 div 与父 div 一起滚动
【发布时间】:2017-07-29 03:21:02
【问题描述】:

我有这两个 div:父 div #filterSelect 包含一组过滤器,其子 div #applyFilterIKnow 是“应用过滤器”按钮。 #applyFilterIKnow 应该始终可见并固定在 #filterSelectdiv 的底部。问题是#applyFilterIKnow#filterSelect 一起滚动。这是两者的 CSS:

#filterSelect {
    transform: translateX(100%);
    transition: transform 0.3s;
    overflow-x: auto;
    overflow-y: auto;
    width: 15%;
    position: absolute;
    z-index: 1000;
    right: 0;
    height: 100%;
}

#applyFilterIKnow {
    position: fixed;
    width: 100%;
    height: 50px;
    bottom: 0;
    right: 0;
    background-color: #4370d9;
    transition: all 0.5s ease;
    font-size: 2rem;
    padding-top: 10px;
    text-align: center;
    color: white;
    cursor: pointer;
}

我省略了一些与背景颜色相关的 css。据说其中一种解决方案是将#filterSelect 的位置设置为相对,但这会使整个div 与页面内容的其余部分重叠。我能做些什么?提前感谢任何回答我的疑问的人:(

这里是一些与问题相关的截图:

【问题讨论】:

    标签: jquery html css sass


    【解决方案1】:

    问题是,你的父母也是绝对的。绝对(或固定)定位元素托管在绝对定位父元素中时的行为不同:它们仍然遵循其父元素的约束。

    唯一可能的方法(我知道)是将固定元素移到其父元素之外。

    【讨论】:

    • 感谢您的回答!我会看看我能不能做到这一点,因为这已经构建了,也许我必须改变很多 os js :s
    猜你喜欢
    • 1970-01-01
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    相关资源
    最近更新 更多