gpt4 book ai didi

css - 修复了不随页面滚动的 div 模态

转载 作者:太空宇宙 更新时间:2023-11-04 03:48:41 25 4
gpt4 key购买 nike

我的页面上有一个 html/css 模态,托管在这里: http://yousolutions.co.za/#openModalViewCreateClient

但是,我需要能够使用页面上的主滚动条向下滚动并查看此表单的其余部分。我当前的 CSS 不允许这样做,我不想在 div 中添加另一个滚动条。我的代码如下所示:

HTML:

<div id="openModalViewCreateClient" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Add A Client</h2>
<form class="contact_form" action="#" method="post" name="contact_form">
<ul>
<li>
<h2>Add New Client</h2>
</li>
<li>
<label for="name">First Name:</label>
<input type="text" placeholder="John" required />
</li>
<li>
<label for="name">Last Name:</label>
<input type="text" placeholder="Doe" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="john_doe@example.com" required />
<span class="form_hint">Proper format "name@something.com"</span>
</li>
<li>
<label for="website">Website:</label>
<input type="url" name="website" placeholder="http://johndoe.com" required pattern="(http|https)://.+"/>
<span class="form_hint">Proper format "http://someaddress.com"</span>
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" type="submit">Submit Form</button>
</li>
</ul>
</form>
</div>
</div>

CSS:

.modalDialog:target {
opacity:1;
pointer-events: auto;
}

.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}

.modalDialog > div {
width: 630px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}

.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }

最佳答案

你正在使用

position: fixed;

.modalDialog 上,视口(viewport)滚动在这种情况下对模式没有任何影响

尝试绝对定位-

position: absolute;

关于css - 修复了不随页面滚动的 div 模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23723431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com