2012-09-14 38 views
0

不知道如何解釋這一點,但這裏有雲:的fancybox內嵌有沒有滾動條和100%和「固定」

相反的fancybox的打開頁面上的「盒子」可以有內部滾動條它要查看溢出的內容,我希望內容僅位於當前/父級內容的頂部。

所以,目前,如果瀏覽器的內部寬度是800px,並且您打開的內容需要1200px高度,那麼Fancybox的'box'高度可以設置爲800px,滾動條用於滾動內容新的「框」(因爲內容是1200px)。我想這樣做,所以沒有新的滾動條,但新的內容是完整的1200px,它將主/父頁面向下推動(如果父頁面上沒有滾動條,則強制滾動條)。

單擊關閉按鈕仍然會關閉它。

這可能嗎?我有道理嗎?

這是的fancybox 2

+0

看來,V2.1.0會幫助你T的值o實現這一點。 – JFK

+0

嗨,謝謝你的回答。我無法在v2.1中的任何地方看到可能的地方。你能提供一個指向文件的鏈接嗎? – user1612824

回答

3

所以對於這個網站

<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);其他類型的內容可以像上面的代碼那樣調整爲widthheight的尺寸。

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"); 
} 
}); 
+0

This chunk: **滾動:「no」,//所以沒有滾動條在fancybox裏面 beforeShow:function(){ this.height = $(this.element).data(「height」); } ** 是什麼修復它對我來說。 – caroline

相關問題