3
我使用的活動源的HTML5嵌入代碼如下記載:我可以動態調整Facebook Activity Stream插件的大小嗎?
http://developers.facebook.com/docs/reference/plugins/activity/
我想Facebook的活動流「補」這是包箱。這個封閉的框可調整大小,所以我需要調整封閉框的大小時調整該活動流。
我使用的活動源的HTML5嵌入代碼如下記載:我可以動態調整Facebook Activity Stream插件的大小嗎?
http://developers.facebook.com/docs/reference/plugins/activity/
我想Facebook的活動流「補」這是包箱。這個封閉的框可調整大小,所以我需要調整封閉框的大小時調整該活動流。
活動饋送插件使用iframe進行渲染,並且無法使用純CSS調整其大小。但是,使用JavaScript,您可以通過重新加載具有正確高度的iframe作爲參數來調整插件的大小。這是一個更快的方法,然後再解析XFBML標記。
CSS(以確保插件元素都遵循容器大小)
.fb-activity, .fb-activity * {
position:relative !important;
width:100% !important;
height:100% !important;
}
的Javascript(使用jQuery)
$(window).resize(function() {
//Calculate the new height of your container
//...
var $container = $('.container');
var $iframe = $container.find('iframe');
$container.css('height',containerHeight+'px');
if($iframe.length) {
$iframe.attr('src',$iframe.attr('src').replace(/height=[0-9]+/gi,'height='+escape(containerHeight)));
} else {
$container.find('.fb-activity').attr('data-height',containerHeight);
}
});