2

の位置を変更することは可能gritterですか? それとも、span や div などの要素にバインドしたほうがよいでしょうか?

私はもう試した:

        $.gritter.add({
            title: 'Dashboard',
            text: 'Field updated!',
            time: 2000,
            position: 'center'
       });

(buttom、top ectでも試しました)しかし、位置は変わりません

4

5 に答える 5

11

ドキュメントを読むと、このようにグリッターを中央に配置できないようです。「左下」、「右下」、「左上」、「右上」のみです

$.extend($.gritter.options, { 
    position: 'bottom-left', // defaults to 'top-right' but can be 'bottom-left', 'bottom-right', 'top-left', 'top-right' (added in 1.7.1)
    fade_in_speed: 'medium', // how fast notifications fade in (string or int)
    fade_out_speed: 2000, // how fast the notices fade out
    time: 6000 // hang on the screen for...
});

css で位置を変えたら?

于 2013-08-27T09:25:40.330 に答える
3

あなたが試すことができます...

//css

.gritter-center{
position:fixed;
left:33%;
right:33%;
top:33%
}

//Javascript

$.gritter.add({
 title: 'This is a centered notification',
 text: 'Just add a "gritter-center" class_name to your $.gritter.add or globally to   $.gritter.options.class_name',
 class_name: 'gritter-info gritter-center'  
});
于 2014-10-13T04:47:42.523 に答える
2

カスタム クラス 'center' を特定の css ファイルに追加します

#gritter-notice-wrapper.center {
    position:fixed; 
    left:33%; 
    right:33%; 
    top:33%;
}

css パラメータを微調整して、グリッター通知の位置を調整します。

  • jquery.gritter.js に回避策を作成します (add 関数の int...)

ラインを交換する

position = $.gritter.options.position,

position = params.position || $.gritter.options.position,

最後に追加グリッター関数を呼び出します

$.gritter.add({
            title: 'Dashboard',
            text: 'Field updated!',
            time: 2000,
            position: 'center'
       });
于 2015-12-07T11:29:52.727 に答える
1

左と上の位置のように CSS で位置を変更します。

$("#gritter").css('left',"100px");
$("#gritter").css('top',"20px");
于 2013-08-27T09:25:14.273 に答える