我想增加彈出背景的高度,同時從下拉列表中選擇項目。彈出窗口的背景應等於下拉列表的高度,同時選擇項目。增加彈出背景的高度
此外,如果我點擊彈出的背景外,它消失。我想顯示彈出的背景,直到從下拉列表中選擇任何項目。
的Html
<div class="maintext">
<h2> Main text goes here...</h2>
</div>
<div id="boxes">
<div id="dialog" class="window">
<div id="san">
<section>
<select class="cs-select cs-skin-elastic">
<option value="" disabled selected>Select a Country</option>
<option value="france" data-class="flag-france">France</option>
<option value="brazil" data-class="flag-brazil">Brazil</option>
<option value="argentina" data-class="flag-argentina">Argentina</option>
<option value="south-africa" data-class="flag-safrica">South Africa</option>
</select>
</section>
</div>
</div>
<div style="width: 2478px; font-size: 32pt; color: white; height: 1202px; display: none; opacity: 0.4;" id="mask"></div>
</div>
CSS
#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color:#26262c;
display:none;
}
#boxes .window {
position:absolute;
left:0;
top:0;
width:440px;
height:850px;
display:none;
z-index:9999;
padding:20px;
border-radius: 5px;
text-align: center;
}
#boxes #dialog {
width:450px;
height:auto;
padding: 10px 10px 10px 10px;
background-color:#ffffff;
font-size: 15pt;
}
.agree:hover{
background-color: #D1D1D1;
}
.popupoption:hover{
background-color:#D1D1D1;
color: green;
}
.popupoption2:hover{
color: red;
}
jQuery的
$(document).ready(function() {
var id = '#dialog';
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(500);
$('#mask').fadeTo("slow",0.9);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
//if mask is clicked
$('#mask').click(function() {
$(this).hide();
$('.window').hide();
});
});
一旦我選擇下拉列表的值,它的工作很好..again我選擇相同的價值,它不工作 –
@IvinRaj是的,你是對的,更新了我的答案。請立即檢查。 thnks –
是的,它工作得很好,謝謝@Manoj Lodhi –