所以對於這個網站
<a class="fancybox" href="{target content}">open content at 1200px height</a>
使用這個腳本
$(".fancybox").fancybox({
type: "html", // set type of content -Supported types are 'image', 'inline', 'ajax', 'iframe', 'swf' and 'html'
width: 800, // or whatever
height: 1200,
autoSize : false, // so the size will be 800x1200
autoCenter: false, // so fancybox will scroll down if needed
fitToView : false, // so fancybox won't try to scale the content to the size of the browser window
scrolling : "no" // so no scroll bars inside fancybox
});
注意:不能設置特定尺寸的圖像,他們將(當fitToView
設置爲false
)或縮放到視口(當fitToView
設置爲true
);其他類型的內容可以像上面的代碼那樣調整爲width
和height
的尺寸。
TIP:你可能具有不同高度的打開不同類型的內容(或目標不同的內容)的每個和動態使用HTML5 data-*
屬性改變的fancybox的height
....所以對於這個網站:
<a class="fancybox" href="{target content 01}" data-height="1200">open content 01 at 1200px height</a>
<a class="fancybox" href="{target content 02}" data-height="1000">open content 02 at 1000px height</a>
<a class="fancybox" href="{target content 03}" data-height="1450">open content 03 at 1450px height</a>
然後回調beforeShow
添加到您的腳本得到的data-height
這樣
$(".fancybox").fancybox({
type: "html", // set type of content -Supported types are 'image', 'inline', 'ajax', 'iframe', 'swf' and 'html'
width: 800, // or whatever
// height: 1200, // no fixed height but obtained dynamically
autoSize : false, // so the size will be 800x1200
autoCenter: false, // so fancybox will scroll down if needed
fitToView : false, // so fancybox won't try to scale the content to the size of the browser window
scrolling : "no", // so no scroll bars inside fancybox
beforeShow : function(){
this.height = $(this.element).data("height");
}
});
來源
2012-09-15 07:35:43
JFK
看來,V2.1.0會幫助你T的值o實現這一點。 – JFK
嗨,謝謝你的回答。我無法在v2.1中的任何地方看到可能的地方。你能提供一個指向文件的鏈接嗎? – user1612824