Css 固定的div模式不与页面滚动
我的页面上有一个html/css模式,托管在这里: 但是,我需要能够使用页面上的主滚动条向下滚动并查看此表单的其余部分。我当前的CSS不允许这样做,我不想在div中添加另一个滚动条。我的代码如下所示: HTML:Css 固定的div模式不与页面滚动,css,html,modal-dialog,fixed,Css,Html,Modal Dialog,Fixed,我的页面上有一个html/css模式,托管在这里: 但是,我需要能够使用页面上的主滚动条向下滚动并查看此表单的其余部分。我当前的CSS不允许这样做,我不想在div中添加另一个滚动条。我的代码如下所示: HTML: <div id="openModalViewCreateClient" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> <
<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>
您正在使用
position: fixed;
在.modalDialog
上,视口滚动在这种情况下对模式对话框没有任何影响
尝试绝对定位-
position: absolute;
这似乎成功了,谢谢!然而,并不是整个背景都是黑色的。底部有一条条纹仍然是白色的,没有变暗。你知道为什么吗?有几个因素导致了这条带-你在边栏上有固定的高度(679px),在.modalDialog>div上应用了边距
position: absolute;