我已經設法讓我的Block UI模態死點,但現在的問題是,當窗口 被調整大小(製作得越來越小或更大)時,模式(以及周圍的疊加層)不會動態調整大小。有沒有一種方法,我可以實現這個使用jQuery?這是我迄今爲止所做的:http://jsfiddle.net/2dpc7/。如果您嘗試拖動結果窗格,則可以看到該模式並未真正動態調整以適合。爲什麼是這樣?獲取模態以在窗口大小調整時動態調整大小
HTML
<div style="float: left;">
<a id="about" class="windowClass" href="#">About</a> ·
<a id="terms" class="windowClass" href="#">Terms</a> ·
<a id="privacy" class="windowClass" href="#">Privacy</a> ·
<a id="language" class="windowClass" href="#">Language: English</a>
</div>
<div id="register_win" class="modal">
<span class="modal_header">Register</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="register_close">
</div>
</div>
<div id="about_win" class="modal">
<span class="modal_header">About</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="about_close">
</div>
</div>
<div id="terms_win" class="modal">
<span class="modal_header">Terms</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="terms_close">
</div>
</div>
<div id="privacy_win" class="modal">
<span class="modal_header">Privacy</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="privacy_close">
</div>
</div>
<div id="forgotpwd_win" class="modal">
<span class="modal_header">Forgotten your password?</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="forgotpwd_close">
</div>
</div>
<div id="language_win" class="modal">
<span class="modal_header">Language</span>
<div class="modal_close">
<img src="http://www.ezpz.co.za/assets/close-button-25f4a789916c34b8c927d7d0ec98410b.gif" id="language_close">
</div>
</div>
CSS
.modal {
display: none;
padding: 10px;
cursor: default;
}
.modal_header {
font-family: Verdana, Geneva, sans-serif;
float: left;
}
.modal_close {
cursor: pointer;
float: right;
}
JS
$(document).ready(function() {
$('.windowClass').click(function() { // <-- bind to all window elements with that class
$.blockUI({
message: $('#' + this.id + '_win'),
css: {
top: ($(window).height() - 200) /2 + 'px',
left: ($(window).width() - 200) /2 + 'px',
width: '200px'
}
});
});
$('[id$=_close]').click(function() { //<-- gets all elements with id's that end with close
$.unblockUI();
return false;
});
});
使用百分比在你的CSS,它會動態調整。你也可以創建一個調整大小的偵聽器:http://snipplr.com/view/9097/ – Jack 2012-07-31 21:13:51