通知Js在底部显示通知

时间:2016-10-06 18:49:47

标签: javascript jquery css notify

我正在使用notify.js插件在我的网站上显示通知。

https://notifyjs.com/

根据文档,默认情况下,通知会显示在右上角。 不知何故,通知会显示在底部。 enter image description here

当通过notify.js中的代码时,它会将body元素附加到body的末尾。所以我将其更改为prepend但是通知仍然显示在底部。

anchor.css(css).addClass(pluginClassName + "-corner");
$("body").append(anchor);

出现这种情况的原因是什么?我应该调试的任何指针? 我用来通知的代码是:

$.notify("Name cannot be empty!","error");

2 个答案:

答案 0 :(得分:1)

我可以看到,当插件被实例化时,一个DOM元素被附加到正文:

<div class="notifyjs-corner" style="top: 0px; right: 0px;"></div>

所有通知都在此DOM元素中创建。

规则 notifyjs-corner 的原始定义是:

.notifyjs-corner {
    position: fixed;
    margin: 5px;
    z-index: 1050;
}

您应该检查是否意外覆盖了CSS规则。

尝试查找并检查该DOM元素。

答案 1 :(得分:1)

通过重新定义页面的默认设置,采用以下方法:

$.notify.defaults({globalPosition: 'top left'})
在这种情况下,

可能会有所帮助。

相关问题