我正在建立我的妹妹網站SarahNWatson.com/new。我把它設置成一個大的照片/視頻專輯。對於實際的內容頁面,比如她的Bio,我擁有這個頁面以便打開一個模式窗口。jQuery動畫高度向外展開而不是向下
現在我有模態窗口,以便高度開始在0px然後動畫打開,但是這給了我一個幻燈片放下的效果。我希望它向外開放,就好像箱子裏有東西在兩個方向推動一樣。我怎樣才能做到這一點?
下面的代碼:
function createModal(filler) {
var $this = $(this);
var $body = $('body');
var winHeight = $(window).height();
var winWidth = $(window).width();
$body.prepend('<div id="blackout">');
$("#blackout").css({ height:winHeight }).fadeIn(1800);
$body.prepend('<div id="modal_window">');
$("#modal_window").html(filler).fadeIn(2000);
var modalHeight = $("#modal_window").height();
var modalWidth = $("#modal_window").width();
var offsetH = winHeight/2 - modalHeight;
var offsetW = winWidth/2 - modalWidth/2;
$("#modal_window").css({ top:offsetH, left:offsetW, height:'0px' }).animate({ height:modalHeight });
}
而CSS:
#modal_window {
position: absolute;
z-index: 1000;
width: 600px;
background: rgba(0,0,0,.8);
padding: 15px;
}
*** ...推動兩個方向...... ***您指的是哪個方向?垂直還是水平? –
垂直在高度 – watzon