固定div模式不滚动页面

时间:2014-05-18 15:13:33

标签: html css html5 modal-dialog fixed

我的页面上有一个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; }

1 个答案:

答案 0 :(得分:0)

您正在使用

position: fixed;

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

尝试使用绝对定位 -

position: absolute;