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

After my data rows are filled, I add jQuery and CSS striping animations to enhance their appearance

Before any click, they have this appearance: Clicking on Sales in the business section reveals a drop-down select box. If I click on "Sales" and modify the text area, it will transition to grey. While the grey rows change accordingly, the black rows shoul ...

Creating a scrolling background effect using HTML and CSS: ``Background Parallax

I'm trying to keep the background of my HTML document fixed in the upper left corner, so that when a user scrolls through the page, they only see parts of it. Here's the code I'm using: <body style="background-image: url(background.png) ...

Error occurs when resizing SVG icon

Having some environmental constraints, I have resized this 16x16 icon to 13.4x16, but it appears blurry. Despite my understanding of SVG and setting the preserveAspectRatio attribute, the resizing does not work as expected. Can anyone point out what I migh ...

Having trouble getting Fullcalendar to show up on my cordova app

Currently, I am in the process of building a mobile application using ionic and cordova. My goal is to incorporate a timetable system utilizing Fullcalendar and a PHP page that showcases MySQL data in JSON format. Despite my efforts, I am encountering diff ...

Determine the state of the checkbox property in HTML

Is there a way to conditionally set the checked property of a checkbox? In my application, I have checkboxes for each row. The database includes a column 'IsSaved' with values of either 0 or 1. If 'IsSaved' is 1 for a particular row, I ...

The click interactions of SVG elements are altered when switching between <img> and <object> elements

I currently have 4 SVG buttons featured in the main menu of my personal website. https://i.stack.imgur.com/gA7En.png /----------------------------------------------------------------------------------------------------------------------------------/ Upo ...

Unable to resize the div to fit the content

My container div is not adjusting its height based on the content inside. It expands according to the header and navigation divs, but not the sidebar which is nested inside another div. Here is the HTML structure: <div id="container"> <div ...

Two full screen divs aligned side by side using float:left

Looking for a way to create UL or DIV elements where each list item/child div takes up the full screen space (100% width, 100% height) and is floated left for horizontal scrolling. Here's my code, but it's not working as expected: HTML: <htm ...

What is the best way to incorporate code into a page with numerous conflicting CSS styles, without resorting to Scoped CSS?

Struggling to incorporate tab code into a page with conflicting CSS? Even after attempts to edit classes and labels, the original code fights back against the new additions. While scoped CSS seems like the perfect fix, it's not widely supported yet. ...

The ng-model value does not display in Angular 1.4.14 <input> after adding an item in ng-repeat loop

I'm facing an issue with the ng-model in ng-repeat of InvoiceLines: - After adding a new Invoice Line for the first time, I type some characters in the ng-model and the input value displays correctly. The InvoiceLines now has 1 line. - However, af ...

Tips for implementing a method to switch CSS properties of a main container by using a checkbox within its child element in a Svelte component

It took me a while to figure this out, but I still feel like my implementation is not ideal. I'm confused as to why things break when I remove the checkedActivities.has(activity) ? "checked" : "unchecked", because I thought TypeScr ...

I'm having an issue where my footer is getting cut off when I resize the browser and start side scrolling. Can

I designed a webpage with a footer that contains another div holding centered content. The footer is supposed to span the entire width, while the inner content div is set to 960px with a margin auto to center it. <footer> <div class="footer-in ...

The integration of Angular 6 with AngularJS components fails to load properly in a hybrid application

Currently, I am in the process of upgrading a large AngularJS version 1.7.3 to a hybrid app using Angular 6. The initial phase involved converting all controllers/directives into an AngularJS component. Subsequently, I created a new Angular 6 project skele ...

AngularJS is experiencing a significant delay in retrieving data from a JSON file for ng-repeat functionality

Dealing with a JSON file containing around 8000 contacts in AngularJS using ng-repeat is causing significant delays. Are there any solutions to improve the performance? ...

Can anyone recommend a high-quality jQuery lightbox replica?

Key Features Needed: Customizable with CSS Capable of handling forms, not just images Extensively documented Please provide any recommendations and suggestions for suitable options. Thank you in advance ...

What is the best way to incorporate an image as an input group addon without any surrounding padding or margin?

Hello, I am currently working on integrating a captcha image into a Bootstrap 4 form as an input group item. It is functioning correctly, but there is an issue with a border around the image causing the input field to appear larger than the others. Below i ...

What could be causing the extra space around my body on mobile devices?

I am currently delving into the world of responsive design, starting from square one. My aim is to create a minimalist webpage with no side margins. However, when viewing it on an iPhone, there still seems to be a significant white margin on either side. T ...

Automatically refreshing the Angular UI-calendar after submitting a form

My use case involves implementing a series of leaves using the Angular UI-Calendar, where the data is fetched from REST services. I can also add leave details to the database. However, there seems to be an issue where the newly added leave details do not a ...

Issue with the Dropdown menu in Metro UI CSS - not functioning properly

I have integrated the METRO UI CSS into my project and created a dropdown menu. The design looks great, but unfortunately, the dropdown list is not appearing as expected. To implement this feature, I followed the example provided on the following link: H ...

Fuzzy text in drop-down box on Chrome, clear on Firefox

I've encountered an issue with a dropdown menu in Google Chrome where the content appears blurry, while it displays correctly in Firefox. The problem arises when the dropdown exceeds a certain height, and I've tried setting a max-height with over ...