-1

我在滚动浏览 我的博客时无法修复我的欢迎栏。我想让 AddThis' 栏在滚动期间固定在顶部边缘。这是代码:

<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-510063517c175536"></script>
<script type='text/javascript'>
addthis.bar.initialize({'default':{
    "backgroundColor": "#EDEDED",
    "buttonColor": "#3CA8FA",
    "textColor": "#FFA733",
    "buttonTextColor": "#FAFAFA"
},rules:[
    {
        "name": "AnyOther",
        "message": "If you enjoy this page, do me a favor:",
        "action": {
            "type": "button",
            "text": "Share this page",
            "verb": "share",
            "service": "preferred"
        }
    },
    {
        "name": "Twitter",
        "match": {
            "referringService": "twitter"
        },
        "message": "If you find this page helpful:",
        "action": {
            "type": "button",
            "text": "Tweet it!",
            "verb": "share",
            "service": "twitter"
        }
    },
    {
        "name": "Facebook",
        "match": {
            "referringService": "facebook"
    },
    "message": "Tell your friends about me:",
    "action": {
        "type": "button",
        "text": "Share on Facebook",
        "verb": "share",
        "service": "facebook"
    }
},
{
    "name": "Google",
    "match": {
        "referrer": "google.com"
    },
    "message": "If you like my blog, let Google know:",
    "action": {
        "type": "button",
        "text": "+1",
        "verb": "share",
        "service": "google_plusone_share"
        }
    }
]});
</script>

有一个名为 showOnScrollTo 的参数(你可以在这里找到关于它的解释),但我不知道如何或在哪里使用它。我试着把CSS“位置:固定;” 在这段代码中的几个地方,但它没有用。如果有人有想法,请帮助。提前致谢

4

1 回答 1

1

要将栏固定在页面顶部,您可以指定参数“fixed”并将其设置为 true,因此始终使栏固定的示例如下:

<script type='text/javascript'>
    addthis.bar.initialize({'default':{
        fixed: true,
        showOnScrollTo: [element | string | integer | float]
        });
</script>

在“默认”对象中,您还可以指定“showOnScrollTo”参数。

于 2013-02-27T15:03:41.370 回答