调整FB.ui()对话框的位置

时间:2021-11-03 19:40:44

I'm using Fb.ui() to post an update to user's wall but the dialog always appears in the same spot in my browser (center middle if scrolled up). The problem is that I'm opening the dialog from the bottom of the screen. Is there a way to get the dialog to show for the user's current scroll location?

我正在使用Fb.ui()将更新发布到用户的墙壁上,但是对话框总是出现在我的浏览器的同一个位置(如果滚动)。问题是我打开了屏幕底部的对话框。是否有办法让对话框显示用户当前的滚动位置?

3 个解决方案

#1


7  

The FB.ui() dialog should already be positionned relative to the place the user scroll currently is.

FB.ui()对话框应该已经定位到相对于用户滚动当前位置的位置。

If not, you can simply position your #fb-root in CSS :

如果没有,您可以简单地将#fb-root放在CSS中:

#fb-root { position:fixed; top:10%; }

That way, the pop-in will always be on the scroll position of the user and also follow it if he continue to scroll up or down the page.

这样,弹出窗口将始终位于用户的滚动位置,如果用户继续向上或向下滚动页面,也将跟踪它。

#2


1  

I'm using this piece of code to set the dialog position to the top of the page, but you can use it to set the position anywhere you want. This code uses the jQuery library

我使用这段代码将对话框的位置设置为页面的顶部,但是您可以使用它来设置所需的位置。此代码使用jQuery库。

            setInterval(function(){
                var dialog = $('.fb_dialog');

                for(var i = 0; i < dialog.length; i++)
                {
                    var d = $(dialog[i]);
                    if(parseInt(d.css('top')) > 0 && parseInt(d.css('top')) != 195)
                    {
                        d.css('top', '195px')
                    }
                }
            }, 500);

#3


1  

The facebook write the dialog html code to the <div class="fb-root"></div> so if you surround it with a <div style="position: absolute;"></div> the dialog appears where you put this code.

facebook将对话框html代码写入

,所以如果你用 对话框出现在您放置此代码的地方。

For example:

例如:

<div style="position: absolute">
<div class="fb-root"></div>
</div>

#1


7  

The FB.ui() dialog should already be positionned relative to the place the user scroll currently is.

FB.ui()对话框应该已经定位到相对于用户滚动当前位置的位置。

If not, you can simply position your #fb-root in CSS :

如果没有,您可以简单地将#fb-root放在CSS中:

#fb-root { position:fixed; top:10%; }

That way, the pop-in will always be on the scroll position of the user and also follow it if he continue to scroll up or down the page.

这样,弹出窗口将始终位于用户的滚动位置,如果用户继续向上或向下滚动页面,也将跟踪它。

#2


1  

I'm using this piece of code to set the dialog position to the top of the page, but you can use it to set the position anywhere you want. This code uses the jQuery library

我使用这段代码将对话框的位置设置为页面的顶部,但是您可以使用它来设置所需的位置。此代码使用jQuery库。

            setInterval(function(){
                var dialog = $('.fb_dialog');

                for(var i = 0; i < dialog.length; i++)
                {
                    var d = $(dialog[i]);
                    if(parseInt(d.css('top')) > 0 && parseInt(d.css('top')) != 195)
                    {
                        d.css('top', '195px')
                    }
                }
            }, 500);

#3


1  

The facebook write the dialog html code to the <div class="fb-root"></div> so if you surround it with a <div style="position: absolute;"></div> the dialog appears where you put this code.

facebook将对话框html代码写入

,所以如果你用 对话框出现在您放置此代码的地方。

For example:

例如:

<div style="position: absolute">
<div class="fb-root"></div>
</div>