Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicated icons with toastr

Tags:

toastr

I have several icons on top of each other in a toastr message. This is what it looks like:

enter image description here

My code is very simple, I use toastr after an Ajax call :

 success        : function(reponse) {
            $(event.target).next('i').hide();
            if (reponse.retour == 0){
                toastr["success"](reponse.texte_retour);
                } else {
                toastr["error"](reponse.texte_retour);
                }
        }

I have the same problem whatever the type (error, info, warning, success). What is going wrong?

like image 864
Dom Avatar asked Jan 24 '16 10:01

Dom


People also ask

What is a Toastr?

toastr is a simple JavaScript toast notification library that is small, easy to use, and extendable. It allows you to create simple toasts with HTML5 and JavaScript like this: Simply include the files in your HTML page and write a simple line of code like this: toastr. success('Are you the six fingered man?

Do Toastrs need jQuery?

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.

What is NGX Toastr in angular?

Toastr is a JavaScript library which is used to create a notification popup. Step 1. Create an Angular project. To create a new project, open command prompt and add the following command to create the Toastr project. ng new Toastr.


Video Answer


4 Answers

Another way to resolve this issue is to load the toastr css before you load the inspinia css. This way Inspinia overwrites the toastr css with its own custom css

like image 66
Hibbem Avatar answered Oct 23 '22 03:10

Hibbem


The issue is solved.

I use 'inspinia framework'. in its style sheet there is already somme css declaration about toastr :

enter image description here

I commented these few lines and now it works fine. Don't know if it is a bug or not on the "inspinia" side.

Dominique

like image 38
Dom Avatar answered Oct 23 '22 02:10

Dom


I had same issue, I checked my reference links to my css, I found that I was calling "toastrStyles" css after "inspania" css. I moved calling my "toastrStyles" css before calling "inspania" css, and it worked for me.

like image 4
Ilham Ibrahimkhalilov Avatar answered Oct 23 '22 04:10

Ilham Ibrahimkhalilov


It looks like you are using font-awesome icons along with the default icons.

Adding this to your css should fix the overlapping icons by hiding the default image.

#toast-container > div.toast {
    background-image: none !important;
}

Also if you want to vertical center your image add

#toast-container > .toast:before {
    position: absolute;
    margin: auto 1.5em auto -1.5em;
    top: 50%;
    transform: translateY(-50%);
}
like image 3
Japheth Adhavan Avatar answered Oct 23 '22 04:10

Japheth Adhavan