【问题标题】:How do I make a CSS element scroll with the page if it is already absolutely positioned?如果 CSS 元素已经被绝对定位,如何让页面随页面滚动?
【发布时间】:2017-09-10 16:00:48
【问题描述】:

我已经实现了一个带有标签的滑入/滑出表单来激活此功能。它就像我想要的那样工作,只是选项卡始终保持在相同的位置,因为它是绝对使用 CSS 定位的。我希望它位于它所在的位置,但要随页面滚动。

这里是 CSS

#slidingform-slider {
width: 500px;
top: 100px;
position: absolute;
}

#slidingform-sidebar1 {
position: absolute !important;
top: 180px !important;
left: 113px !important;
box-shadow: 0 0 8px gray;
z-index: 10000 !important;
}

这里是html

<div id="slidingform-sidebar1" onclick="slidingform_close_panel()">
<button class="contact-slideout-toggle contact-slideout-btn btn btn-lg         btn-primary hidden-xs hidden-sm">Request a Call Back</button>
</div>
<div id="slidingform-header">   
<--- form in here --->
</div>
</div>

【问题讨论】:

    标签: html css drupal


    【解决方案1】:

    我想通了。我只是在整个东西周围放了一个包装器,然后给它下面的 css:

    .slider-wrap {
    position: fixed;
    right: 0;
    z-index: 10000;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-05-06
      • 2019-03-22
      • 1970-01-01
      • 2021-02-10
      • 2021-03-21
      • 2013-02-27
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多