Creating a large and spacious modal in Angular using ngx-bootstrap

I need help with resizing the ngx-modal to cover a large area of the screen. Currently, I am trying to make it so that when something is clicked, the modal should overlay an 80% width grid on a full desktop screen. Despite my attempts at using .modal-xl and overriding max-width properties, the modal does not expand as desired:

div .modal-dialog .modal-xl .modal-dialog-centered {
    max-width: 2500px !important;
    width: 2500px !important;

}

Unfortunately, these adjustments have not been effective. I also experimented with adding classes like dialog-full and container-fluid, but they did not stretch the modal beyond the limits of .modal-xl.

The functionality of the modal itself works perfectly fine; however, I am struggling with the visual formatting. Is there a way to make the ngx-modal fill up such a large portion of the screen? If not, are there alternative solutions available?

Here is how the component's HTML looks (including container-fluid):

<div class="container-fluid">
    <div class="modal-header">
        <div class="modal-body">
            <p>Modal</p>
            <button type="button" class="close" data-dismiss="modal" id="closeModal" (click)="closeModal()">&times;</button>
        </div>
    </div>
    </div>

Below is how the modal is triggered from the parent component (on a click event):

this.bsModalRef = this.modalService.show(MessageDetailComponent, { class: 'modal-xl modal-dialog-centered', backdrop: 'static' });

As a note, the application is running Angular 8.2.14

UPDATE:

To successfully resize the modal, I added the following styles in the styles.scss file:

.container-fluid {
    max-width: 1200px !important;
    width: 1200px !important;
}

.modal-content {
    max-width: 1200px !important;
    width: 1200px !important;
}

.modal-header {
    height: 750px;
    max-width: 1200px !important;
    width: 1200px !important;
}

div .modal-dialog .modal-xl .modal-dialog-centered{
    max-width: 1200px !important;
    width: 1200px !important;
}

It is unclear which specific style change resolved the issue, but now the modal displays as intended - large and wide. Based on the explanation provided below, it appears that updating the modal-content may have contributed to the successful resize.

Answer №1

Check out the live DEMO. When working with library components and CSS customization, it's important to put your style code inside styles.css. This will affect all modals in your application.

.modal-dialog{
  width:100% ;
  height: 100%  ;
  margin: 0 auto;
}
.modal-content{
  width:100% ;
  height: 100%  ;
}

If you only want to apply custom styles to a specific component, you can add a custom class to the modal and target it like this:

.test{
  width:100% ;
  height: 100%  ;
  margin: 0 auto;
}
.test .modal-content{
  width:100% ;
  height: 100%  ;
}

Answer №2

If anyone else is looking for a simpler solution, here's an alternative method to achieve the same result.

All you need to do is create a new class in your style.scss file:

.wide-modal-dialog {
  width:100%;
  max-width: 850px;
  margin: 0 auto;
}

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

Next, include this class as an option before displaying the modal:

const options: ModalOptions = {
      animated: true,
      class: 'wide-modal-dialog',
      initialState: {
        clauseRef: clauseRef
      }
    };
this.bsModalRef = this.modalService.show(ComponentName, options);

By doing this, the specified class will be applied to the main div of the modal.

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

What could be the reason for the file element being undefined in the context menu?

I am currently working on rebuilding my context menu for the second time today. I am encountering an issue with an undefined value of my file element, which is preventing me from deleting, renaming, or performing any other actions. HTML <mat-list-item ...

Dealing with the "net::ERR_CERT_DATE_INVALID" issue within Ionic 4

When sending an "http" request in Ionic4, the response neither falls under the success callback nor gets handled by the error handling block. It just keeps loading indefinitely. I need a solution to properly handle this error in Ionic4 (Client side). I at ...

"Creating Eye-Catching CSS Animation Effects with Dynamic Initial States

I am looking to understand how I can seamlessly transition from a hover-triggered animation to an exit-hover animation, regardless of where the hover animation is in progress. Currently, if I exit hover too quickly, the animation jumps back to its starting ...

Is it possible to replace multiple li elements with multiple ul elements within a single ul for better organization?

In the world of HTML and CSS, there are endless possibilities for creating unique designs. Recently, I stumbled upon an interesting question that has been lingering in my mind without a clear answer. Typically, people use a single "ul" element to create a ...

Achieving a scrollable div with ng-repeat

I have implemented ng-repeat to showcase some messages, and I am attempting to create a scrollable "message_area" as the messages overflow naturally over time. However, my current code is not delivering the desired outcome. <div class="main_area"> ...

Error: The AppModule encountered a NullInjectorError with resolve in a R3InjectorError

I encountered a strange error in my Angular project that seems to be related to the App Module. The error message does not provide a specific location in the code where it occurred. The exact error is as follows: ERROR Error: Uncaught (in promise): NullInj ...

Unusual ways that backgrounds and borders behave while incorporating CSS transitions for changes in height, positions, and transformations

I was under the impression that I had come up with a brilliant idea... I wanted to create a button with a hover effect where the background would do a wipe transition (top to bottom, left to right) using soft color transitions. My plan was to achieve this ...

stacking order of floated and positioned elements

After researching on MDN and reading through this insightful blog post, it is suggested that in the absence of a z-index, positioned elements are supposed to stack above float elements when they overlap. However, upon closer examination, the example prov ...

How to effectively manage radio buttons in Angular 6

Here are some questions I have listed below. public QandAList = [ { question:{ id: "Q1", query:"What is the capital of France?" }, options:[ { id: "opt1", text: "Paris" }, ...

"Creating a HTML Table with Merged Cells using colspan and rowspan

Creating an HTML table with a unique layout is my latest project. I envision it to look like this: +-------+---+ | | | +-------+ + | | | +-----+-----+ | | | +-----+-----+ To achieve this, I'm utilizing a colgroup to split t ...

Angular 2's Stylish Modal Boxes

I've been trying to integrate the fancybox package into my Angular 2 application. I installed it using npm and carefully went through the documentation. However, I encountered an issue where fancybox is not working as expected. Initially, I suspected ...

I want to create a custom jQuery slider totally from scratch

Greetings everyone, I have been tasked with creating a slider using only HTML / jQuery code. Here is the template: And here is the HTML code for the template above: <div id="viewport-container"> <section id="sliding-container"> & ...

Tips on resizing images within a container to maintain aspect ratio

I am trying to create a layout with a flex container containing 2 divs - one with an image that floats left, and the other with some paragraphs floating right. How can I make sure that the image scales alongside the paragraphs while maintaining its aspect ...

The card-img-overlay in Bootstrap 5 seamlessly integrates into the following div container

Currently, I am in the process of creating a painting website layout for my CS50 homepage. However, there seems to be an issue with the background-color: rgba(0,0,0,0.7); not aligning correctly with the images within the card-group. <div class="car ...

"Encountering a glitch with masterpage.cs in Aspx.net and C#

Currently facing a perplexing issue while developing a website using aspx.net and c#. The following code snippet is on my masterpage: protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Request.Url.AbsolutePath == "/ ...

Guide to automatically converting Google fonts to base64 for inline use

I am currently in the process of creating my own personal blog using next.js. While everything is going smoothly with the use of Google Fonts for font styling, I have encountered an issue with initial content shift upon loading. This occurs when a new fon ...

Error TS2322: This type cannot be assigned to type 'never' in Angular

Trying to incorporate the websocket (sockjs and stomp) into my Angular project for a chat messaging feature, I encountered an issue in my service.ts file. Specifically, when I defined the addMessage method like so: public messages = []; addMessage(messa ...

Executing functions before the data is loaded in an Angular application

Hey there, I'm relatively new to Angular and I've been facing some difficulties when it comes to loading data. In the code snippet below, you'll notice that I have two services being called. Each service logs something to the console. After ...

Comparing dates in Angular and Ionic: A breakdown

I am facing an issue with comparing dates in my ion-datetime input and a date variable obtained from the server. The problem arises because when I retrieve the value from the input, it includes the time field along with the date. As a result, using the get ...

"Enhance Your Table Design with Zebra Cells Using CSS in rich:data

How can I achieve a zebra color effect in every other cell of a rich:dataTable using CSS? <rich:dataTable value="#{uploader.files}" var="_data" id="files"> <rich:column> <f:facet name="header"> <h:outputText ...