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?
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.
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.
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.
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With