Changing the size of the Modal Panel in Ui Bootstrap for a customized look

Currently, I am in the process of developing an application that utilizes Ui bootstrap to seamlessly integrate various Bootstrap components with AngularJs. One of the key features I require is a modal panel, however, I found that the default size option 'lg' (large) does not meet my specific needs. Consequently, I decided to customize it. According to the official documentation, customization involves passing a CSS class when opening the modal using the 'windowClass' property. In order to achieve this, I created a CSS class named 'modal-huge' as shown below:

.modal-huge .modal-dialog {
width: 80%;
}

.modal-body
{
height: 80%;
}

Subsequently, I applied this newly created class as a parameter when initializing the modal panel:

var modalInstance = $modal.open({
            templateUrl: 'productDetail.html',
            controller: 'ProductDetailController',
            windowClass: 'modal-huge',
            resolve:{
              productDetail: function (){
              $scope.hideLoader();
              return response;
              }
            }

          });

My approach involved using percentage values for both width and height attributes to ensure a responsive design that adapts based on the screen size and the parent element's dimensions. However, I encountered a problem where the height adjustments were only being recognized when specified in pixels (px) rather than percentages, thus disrupting the responsiveness of the design. Any insights on what might be causing this issue or potential solutions would be highly appreciated. Thank you in advance!

In case additional context is necessary, here are snippets of the remaining code:

The structure of the modal panel:

 <div>
 <script type="text/ng-template" id="productDetail.html">


    <div class="modal-header">
        <h3 class="modal-title">Product</h3>
    </div>
    <div class="modal-body">


    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" data-ng-click="ok()">OK</button>
        <button class="btn btn-warning" data-ng-  click="cancel()">Cancel</button>
    </div>


 </script>

</div>

Furthermore, the body section includes the modal panel referred to as 'productDetailPanel':

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


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

   <toaster-container toaster-options="{'position-class': 'toast-container-custo','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>

    <!-- This is the div with the overlay css class, so no matter where it  is located this div inside the screen, it will cover the whole screen-->
        <div id="loader" class="loading overlay" data-ng-if="loader.loading">
            <p>{{loader.loadingMessage}}</p>
            <img alt="" src="images/ajax-loader.gif">
         </div>

    </div>

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

</body>

Answer №1

To make % height function properly, it is necessary to assign a height to the parent element as well. In the case of the .modal-body example, the parent element is .modal-content which, in turn, has .modal-dialog as its parent.

Consider implementing something along these lines

.modal-dialog, .modal-content {
  height: 100%;
}

.modal-body {
  height: 80%;
}

Alternatively, you can explore similar inquiries Set bootstrap modal body height by percentage

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Deactivate the form element when a user selects another button

I am facing an issue with two buttons that are linked to the same modal form. Here is the code snippet for the form: <form name="addUser" ng-submit="(addUser.$valid) ? add() : '';"> <div class="form-group has-feedback" ng-class="ad ...

What are the steps for integrating bootstrap into an Angular project?

I recently added Bootstrap to my Angular project using the npm install bootstrap command and referencing the necessary CSS file in the styles property of the angular.json file. However, when I run my application, I notice that Bootstrap is not being applie ...

Modifying an image with jQuery

Why won't this image change? Below is the relevant HTML, CSS, and jQuery code. HTML <nav id="desktop-nav"> <div class="logo"> <a href="#"></a> </div> <div> ... </div> ... CSS nav#desktop-nav . ...

Dynamically fetching and uploading files from a specific path using Node.js, Express, and Angular 1.x

How can I upload or move all files from a specific folder using NodeJS, Express, and Angular 1.x by providing the folder path? What is the best way to handle this operation in either Angular or Node? Should I use: var fs = require('fs') module ...

Center alignment of text and images within the button's image

Can someone help me format my CSS properly? I have a button image where the text should be on the left side and another image on the right side. Currently, everything is centered. Thank you in advance. Here is the current code: button { /* padding- ...

Issues arise when attempting to display a div element in AngularJS based on the value of a hidden input

I have been struggling to make my div elements appear based on a hidden input value in the code snippet below: <form method="post"> <fieldset data-ng-app=""> <input type="hidden" id="Method" name="Method" value="1" data-ng-model="meth ...

Why doesn't jQuery UI's addClass method animate visibility like it should?

One of the advantageous features of jQuery UI is its enhancement of the jQuery addClass method, which enables animation by including a second parameter for 'duration', as shown below: $('div').addClass('someclass', 1000); Th ...

Expand Bootstrap accordion on hover

I have tried several examples that I discovered on Google and Stack Overflow, but none of them seem to work. So, I decided to attempt a different solution for opening the Bootstrap accordion on hover, however, it is not working as expected. Do you have any ...

The CSS class is specifically assigned to a single element

After every two seconds, my JavaScript function is triggered and based on certain logic, I aim to add a CSS class with an effect to an HTML element on the page. var counter = 0; $interval(function () { counter++; ...

The h3 element is not responding to the adjacent sibling selector

Below is my HTML DOM structure. I am trying to remove the margin and padding for all h3 elements that are immediate siblings of a div with the id "successor". I attempted to achieve this using the adjacent sibling selector "+", but unfortunately, I'm ...

Unable to specifically identify or focus on this offspring

I am attempting to target the class has-translucent-status-bar nested within another class called platform-ios To achieve this, I have used the following code: .platform-ios > .has-translucent-status-bar Unfortunately, this approach has not been succ ...

Using AJAX to connect the JSP page with the Servlet's doGet() function for interaction

Currently, I am working on the JAVA code provided below in order to make a call to the servlet's doGet() method from a JSP page using an AJAX request. This is how my AJAX call looks like: I am passing the clicked text captured by ng-click of Ang ...

Is there a way to eliminate the underline in TextField components in Material-UI?

Is there a way to remove the underline from a material-ui TextField without using InputBase? I would prefer to stick with the TextField API, but have not been able to find a solution in the documentation. ...

Split-button dropdowns within tabs implemented with Bootstrap

I'm looking to create a navigation menu that combines both split buttons and dropdown tabs. I've found examples of each individually, but can't figure out how to merge the two: "Tabs with dropdowns" Is it possible to have a tab with a drop ...

The datapicker feature permits the selection of dates that are considered invalid

If a user does not know the exact date, how can I allow them to input something like '99/99/9999'? $('#date').datepicker({ language: "pt-BR", autoclose: true, format: 'dd/mm/yyyy', todayHighlight: true }) Whe ...

Odd gap beside Bootstrap5 navbar that needs fixing

While working on a layout featuring a left-sided nav-bar menu, I encountered an odd blank space between the navbar and the main content area. Can anyone shed light on why this space appears and how to eliminate it? For reference, here is the code snippet: ...

Achieve this effect by making sure that when a user scrolls on their browser, 50% of the content is entered into view and the remaining 50%

Is there a way to achieve this effect? Specifically, when the user scrolls in the browser, 50% of the content is displayed at the top and the other 50% is shown at the bottom. ...

Creating a Python server for an Angularjs application and capturing user input

Can you offer me some assistance, whether it's just a hint or a useful tip that could improve my current approach? I have created a series of forms using HTML and AngularJS. Each form collects input data from users, which is then stored in a JSON str ...

Title vanishes when gradient is added to a div

I have encountered an issue with a recent update on my webpage. Previously, I had multiple divs with the title attribute that displayed information when users hovered over them. However, after adding a gradient background, the titles stopped appearing. Th ...

unexpected automatic scrolling that occurs when hovering over an element

a sudden scrolling takes effect simultaneously with hovering on an element. What confuses me more is that it does not happen every time I hover over the element but just occasionally or maybe there is a specific scrolling position that I can't see yet ...