Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center toastr notifications within a div

I'm trying to get my toastr notification to show up in the middle of a div. I've seen some suggestions, like this one, but it's centering based on the overall window, and not within a div.

Is it possible to center a toast notification within a form element, when toastr knows nothing about the elements on a form?

My latest attempt was to roughly center the toast within the page, but I'd like to center it within a certain div. Is that possible? If so, how?

This is my centering attempt:

.toast-center {
    top: 50%;
    left: 40%;
}

enter image description here

like image 540
Bob Horn Avatar asked Apr 06 '13 15:04

Bob Horn


People also ask

What is Toastr notification?

Toast Notifications notify the user of a system occurrence. The notifications should have a consistent location in each application.

What is Toastr CSS?

toastr is a Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.


1 Answers

You can try to create a new div and position it in the center of your expected div.

Then you can use positionClass option of toastr which is the location for your notification to popup

toastr.options: {
    "positionClass": "your-newly-created-div-class"
}
like image 90
Eli Avatar answered Oct 14 '22 05:10

Eli