固定位置在模态窗口上不起作用

时间:2019-10-21 16:27:39

标签: javascript html css position fixed

我有用于“模态”和CSS的HTML。在CSS中,我定义了modal-footermodal-fixed-footer类。 modal-fixed-footer类不会导致该项目“粘”在屏幕上,它仍会滚动。

<div class="body-blackout"></div>
<button class="btn-big ripple ripple-effect popup-trigger" data-popup-trigger="one">
    Popup Trigger Two
</button>
<button class="btn-big ripple ripple-effect popup-trigger" data-popup-trigger="two">
    Popup Trigger Two
</button>
<div class="popup-modal" data-popup-modal="one">
    <div class="popup-modal-close"></div>
    <h5>Modal One Title</h5>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget lacus
        quis velit viverra iaculis. Interdum et malesuada fames ac ante ipsum 
        primis in faucibus. Vestibulum maximus ipsum ex. Curabitur elementum 
        luctus augue, quis eleifend tortor feugiat vel. Maecenas maximus, ipsum 
        et laoreet congue, diam massa aliquam libero, at pellentesque orci ipsum 
        et velit. Aliquam at ligula nec mi gravida facilisis. Etiam tempor 
        egestas mauris at suscipit.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget lacus
        quis velit viverra iaculis. Interdum et malesuada fames ac ante ipsum 
        primis in faucibus. Vestibulum maximus ipsum ex. Curabitur elementum 
        luctus augue, quis eleifend tortor feugiat vel. Maecenas maximus, ipsum 
        et laoreet congue, diam massa aliquam libero, at pellentesque orci ipsum 
        et velit. Aliquam at ligula nec mi gravida facilisis. Etiam tempor 
        egestas mauris at suscipit.
    </p>
    <div class="modal-fixed-footer">
        <button class="btn-text ripple ripple-effect ripple-red">Disagree</button>
        <button class="btn-text ripple ripple-effect ripple-green">Agree</button></div>
    </div>
    <div class="popup-modal shadow" data-popup-modal="two">
        <div class="popup-modal-close"></div>
        <h5>Modal With Fixed Footer Title</h5>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget lacus
            quis velit viverra iaculis. Interdum et malesuada fames ac ante ipsum 
            primis in faucibus. Vestibulum maximus ipsum ex. Curabitur elementum 
            luctus augue, quis eleifend tortor feugiat vel. Maecenas maximus, ipsum 
            et laoreet congue, diam massa aliquam libero, at pellentesque orci ipsum 
            et velit. Aliquam at ligula nec mi gravida facilisis. Etiam tempor 
            egestas mauris at suscipit.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget lacus
            quis velit viverra iaculis. Interdum et malesuada fames ac ante ipsum 
            primis in faucibus. Vestibulum maximus ipsum ex. Curabitur elementum 
            luctus augue, quis eleifend tortor feugiat vel. Maecenas maximus, ipsum 
            et laoreet congue, diam massa aliquam libero, at pellentesque orci ipsum 
            et velit. Aliquam at ligula nec mi gravida facilisis. Etiam tempor 
            egestas mauris at suscipit.
        </p>
        <div class="modal-footer">
            <button class="btn-text ripple ripple-effect ripple-red">Disagree</button>
            <button class="btn-text ripple ripple-effect ripple-green">Agree</button>
        </div>
    </div>

1 个答案:

答案 0 :(得分:0)

也许您需要使用此CSS:

.modal-fixed-footer {
    position: sticky;
    bottom: -45px !important;
}

但是考虑到您没有发布CSS,很难理解什么是行不通的。

而且,我无法想象类modal-fixed-footer应该在哪里出现以及如何出现。