【问题标题】:Div set to fixed position not floating with scroll in mobile responsive viewDiv 设置为固定位置,在移动响应视图中不随滚动而浮动
【发布时间】:2017-10-13 03:46:40
【问题描述】:

我正在尝试添加一个粘性/固定条,它应该出现在移动屏幕宽度

以下是我试图浮动在带有固定标题的滚动条上的 div 的 CSS。

#hstickyfor_mobile {
  z-index: 10000;
  transform: translate3d(0, 0, 0);
  position: fixed;
  top: 100px;
  width: 100%;
  height: 100px;
}

谢谢

【问题讨论】:

    标签: html css css-position


    【解决方案1】:

    如果具有transform 属性集(source),则相对于祖先元素设置位置。

    在您的情况下,当您正确设置 position: fixed 时,.mobmenu-push-wrap 元素具有 transform 属性集。所以hstickyfor_mobile元素的位置是相对于.mobmenu-push-wrap元素确定的,它是静态的。

    【讨论】:

    • 非常感谢 Derek,这正是问题所在。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-19
    • 2013-04-01
    • 1970-01-01
    相关资源
    最近更新 更多