Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to give the size of the modal in the options

I am using bootstrap modal to show messages:

 var options = {
          backdrop: false,
          keyboard: true,
          backdropClick: false,
          templateUrl: 'a.html',
          controller: 'aController',  
        };
 var modalInstance = $modal.open(options);

Is it possible to give the custom width and height style properties?

like image 463
Patan Avatar asked Nov 26 '14 10:11

Patan


People also ask

How do you size a modal?

Modal Size Change the size of the modal by adding the . modal-sm class for small modals, . modal-lg class for large modals, or . modal-xl for extra large modals.

How do I resize react modal?

The Dialog supports resizing feature. To resize the dialog, we have to select and resize it by using its handle (grip) or hovering on any of the edges or borders of the dialog within the sample container.

How can I increase my modal height?

In order to increase or decrease the modal window height and width properties of Bootstrap, you need to get the modal related classes and use desired values either in the <style> section or in your external CSS file.


2 Answers

Yes you can provide a size key value(sm, md, lg) which interpolates to .modal-sm, .modal-md and .modal-lg.

As stated in the angular-bootstrap documentation:

size - optional size of modal window. Allowed values: 'sm' (small) or 'lg' (large). Requires Bootstrap 3.1.0 or later

Javascript

 var options = {
          backdrop: false,
          keyboard: true,
          backdropClick: false,
          templateUrl: 'a.html',
          controller: 'aController',
          size: 'lg' // sm, md, lg
 };
 var modalInstance = $modal.open(options);

If you are not satisfied with the size provided by those values, then you have two options:

[1] Add a class to the top level modal window using the windowClass attribute and then use this class to change the respective elements via css child selectors.

[2] You can also change the template using the windowTemplateUrl and override the default template implementation or create one yourself.

like image 116
ryeballar Avatar answered Sep 23 '22 15:09

ryeballar


Angular UI Bootstrap applies a conditional class to each modal based on what string is passed in as a size option to modalInstance.

<div class="modal-dialog" ng-class="size ? 'modal-' + size : ''">

You can pass in a custom string to create a class in the format modal-[yourSizeString]. Extend the default modal sizes by passing in size: 'xl' or something similar to generate the class modal-xl which can be styled with a custom width.

JS

myOpenFunc = function () {
    var modalInstance = $modal.open({
        animation: true,
        templateUrl: 'mypage.html',
        size: 'xl',
        controller: 'myCtrl'
    });
};

CSS

.modal-xl {
    width: 1200px;
}
like image 42
shanzilla Avatar answered Sep 20 '22 15:09

shanzilla