Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust toaster popup width

I'm using AngularJS-Toaster to popup notifications in my app. For the frontend I'm using bootstrap.

Using the class 'container' I have a grid of 1200px. Inside I have a div with the popup notifications.

I would like to adjust the width of the popup notification to the same width that the container where this toaster is included in. I saw that toaster has a parameter 'position-class' to change the position and even the width of the popup, like for example 'toast-top-full-width', but using that I get a full screen notification, it is not adjusting to the container where it is included. I guess this is something that could be done using Css, but how? Could you please help me?

Here my html code:

<body data-ng-controller="AppController">


    <div id="container" class="container">

   <toaster-container toaster-options="{'position-class': 'toast-container','time-out': 3000, 'close-button':true}"></toaster-container>

        <div id="header" data-ng-include="'partials/header/header.html'" ></div>



        <div data-ng-view></div>
        <div id="footer" data-ng-include="'partials/footer/footer.html'"></div>


        <div id="loader" class="loading overlay" data-ng-if="loader.loading">
            <p>We are loading the products. Please wait...</p>
            <img alt="" src="images/ajax-loader.gif">
         </div>   

    </div>

    <div id="loginPanel" data-ng-include="'partials/content/panels/login.html'"></div>

Thank you very much in advance.

like image 838
fgonzalez Avatar asked Jan 21 '15 00:01

fgonzalez


3 Answers

You can change class for your toaster to toast-top-full-width

 <toaster-container toaster-options="{'time-out': 3000, 'close-button':true, 'position-class':'toast-top-full-width'}"></toaster-container>

OR you can create custom css rule and apply it to your toaster ie.

  <toaster-container toaster-options="{'time-out': 3000, 'close-button':true, 'position-class':'my-toast-class'}"></toaster-container>

Check example :- http://plnkr.co/edit/1nZygN?p=preview

like image 118
sylwester Avatar answered Nov 04 '22 19:11

sylwester


You could just use CSS to set the width to 1200px or 100% or any other length.

#toast-container > .toast {
  width: 1200px; /* width: 100% */
}

The value 'auto' is already defined for the margin-left and margin-right properties. So if one wants a little bit of spacing on the sides, I'd use:

#toast-container > .toast {
    max-width: 1200px;
    width: 90%;
}
like image 41
chri3g91 Avatar answered Nov 04 '22 19:11

chri3g91


We can set the toastr options in javascript file as below:-

toastr.options = {
   "positionClass": "toast-bottom-full-width",
   ...
};
like image 2
20B2 Avatar answered Nov 04 '22 20:11

20B2