我一直在創建具有某些不同功能的彈出窗口。它被用作用戶訂閱我的網站的流行音樂。我已經添加了一個連接我的數據庫的表單,這一切都很好。我現在試圖添加一些自定義功能。將Overlay添加到彈出框並添加輸入類型字段以退出表單
我想一些重疊(淡出)添加到我的彈出窗口的背景,使我的主頁時,在彈出的
我需要在輸入類型字段中添加的背景(淡出如果可能的話)關閉我的表單。 *我一個圖像中已經添加了X,如果沒有,我會用這個退出該
這裏輸入類型的選擇是我的代碼:
的JavaScript:
<script>
function PopUp(hideOrshow) {
if (hideOrshow == 'hide') {
document.getElementById('ac-wrapper').style.display = "none";
}
else if(localStorage.getItem("popupWasShown") == null) {
localStorage.setItem("popupWasShown",1);
document.getElementById('ac-wrapper').removeAttribute('style');
}
}
window.onload = function() {
setTimeout(function() {
PopUp('show');
}, 0);
}
function hideNow(e) {
if (e.target.id == 'ac-wrapper') document.getElementById('ac-wrapper').style.display = 'none';
}
HTML:
<div id="ac-wrapper" style='display:none' onClick="hideNow(event)">
<div id="popup">
<img alt="#" class="close-image" src="Assets/images/Deep_Close.png" />
<form name="Mail_list" action="save.php" method="post">
<br/>
<h4>Subscription</h4>
<br/>
<div class="form-group">
<label for="first_name">First Name: </label>
<input type="text" name="first_name" id="first_name" size="25" placeholder="First Name" autofocus required />
</div>
<div class="form-group">
<label for="last_name">Last Name: </label>
<input type="text" name="last_name" id="last_name" size="25" placeholder="Last Name" required />
</div>
<div class="form-group">
<label for="email">User Email: </label>
<input type="text" name="email" id="email" size="25" placeholder="Email" required />
</div>
<br/><br/>
<input type="submit" value="Submit Form">
<input type="reset" value="Reset Form">
</form>
CSS:
#ac-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1001;
}
#popup{
position:absolute;
display:hidden;
top:300px;
left:50%;
width:500px;
height:auto;
margin-left:-250px;
background-color:white;
z-index:6;
padding:20px;
border:solid 5px #333333;
border-radius:5px;
}
#overlay-back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
opacity: 0.6;
filter: alpha(opacity=60);
z-index: 5;
display: none
}
.close-image{
display: block;
float:right;
position:relative;
top:-15px;
right: -15px;
height: 20px;
}
正如你可以看到我已經在「疊加」 CSS增加了,我只是不知道如何在我的彈出,使功能工作實現這個。
另外,'close-image'CSS將用於關閉窗體,如果他們沒有可用的輸入類型來關閉窗體(我一直無法找到),我如何實現這個是我的JavaScript的?