You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Blazorise NotificationService:修改默认通知位置至顶部中央

调整Blazorise Notification至顶部居中位置

全局默认配置(推荐)

在项目的服务注册文件(如Program.cs)中,配置Blazorise时直接指定通知的默认位置:

builder.Services.AddBlazorise(options =>
{
    options.Notification.Position = NotificationPosition.TopCenter;
});

单条通知单独设置

如果仅需对某一条通知调整位置,调用Notify方法时传入Position参数:

await notificationService.Notify(new NotificationOptions
{
    Message = "通知内容",
    Position = NotificationPosition.TopCenter
});

CSS覆盖(备选方案)

若上述方法未生效,可通过自定义CSS强制修改容器位置:

.blazorise-notification-container.top-center {
    top: 1rem;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
}

将这段样式添加到全局样式文件(如wwwroot/css/app.css)即可。

内容的提问来源于stack exchange,提问作者Talha Ahmed Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 07:30:54