首页 > 解决方案 > 单击打开 div 的按钮后,如何阻止我的固定位置“覆盖”div 滚动到页面顶部?

问题描述

我试图创建一个可以从固定位置标题在任何点加载的表单,现在实际的表单和覆盖工作,我的问题是当我单击按钮打开所述覆盖时,如果我在它拖动的页面底部页面回到顶部。我该如何阻止它这样做?

我仍然是编码部门的新手,但是,我尝试了多种职位来尝试纠正问题,但没有运气。我不知道是否有一些神奇的 jquery 可以解决这个问题!

<div class="overlay1" id="overlay1">
    <div class="overlayin">
        <i class="fas fa-times" id="hideov1"></i>
        <h2>Request a Quote</h2>
        <p>Want a rough idea of cost for the design or product you need?<br> fill in the form below with as much detail as possible!</p>
        <hr>

        <form>
            <h5>Which service is most relevenent to your project needs?</h5>
            <p>Graphic Design</p>
            <p>Web Design</p>
            <p>I dont Know yet</p>
            <div class="radio1">
                <input type="radio" value="Graphic Design">
                <input type="radio" value="web Design">
                <input type="radio" value="idkyet">
            </div>
            <h5>Could you detail a description of your project?</h5>
            <textarea placeholder="Feel free to list things in bulletpoint form or paragraphs, dont forget the more information you proivde the better we will be able to understand your project!"></textarea>
            <div class="qbox">
                <h5>do you have an budget?*</h5>
                <input type="text" required placeholder="What's your estimated cost?">
                <h5>do you have an budget?*</h5>
                <input type="text" required placeholder="What's your estimated cost?">
                <h5>do you have an budget?*</h5>
                <input type="text" required placeholder="What's your estimated cost?">
            </div>
        </form>
    </div>

</div>
.overlay1 {
    width: 40vw;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    background-color: white;
    z-index: 10001;
    display: none;
    overflow-y: scroll
}

$(document).ready(function () {
    $("#showov1").click(function () {
        $('#overlay1').slideToggle();
    })
});

感谢您提前提供任何帮助

标签: jqueryhtmlcss

解决方案


推荐阅读