Using a Bootstrap 4 modal within a child component in Angular version 6

Encountering an issue while working with the Angular 6 + Bootstrap 4 combination - the modal opens up behind the modal-backdrop. Oddly enough, this is the only modal in the project that behaves this way.

Libraries imported in Angular.json file:

"styles": [            
          "src/styles.scss",
          "node_modules/bootstrap/dist/css/bootstrap.min.css"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.min.js",  
          "node_modules/popper.js/dist/umd/popper.min.js", 
          "node_modules/bootstrap/dist/js/bootstrap.min.js"
        ]

Button to open modal:

  <div class="row">
    <div class="col">
      <button class="btn btn-md" data-toggle="modal" data-target="#modalID">Click Here</button>
    </div>
  </div>

Modal structure (simplified):

<div class="modal fade" id="modalID">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <!-- Header Here -->
      </div>
      <div class="modal-body">
        <!-- Body here -->
      <div class="modal-footer">
        <div class="col-6">
          <!-- Buttons here -->
      </div>
    </div>
  </div>
</div>

All HTML code is within a child component, part of a parent component. See code below:

<div class="row">    
  <div class="col-lg-9">
     <div class="space-bottom">
       <app-given-component></app-given-component>
     </div>
   </div>
</div>

The issue of the modal appearing behind the backdrop could be due to styling on the row class. Removing display:flex; using dev tools fixes the modal positioning, but messes up the rest of the page's styling. Struggling to find a solution without removing row or col-lg-9 classes.

Any help would be greatly appreciated.

Thank you, Alex

Answer №1

Despite unsuccessful attempts with CSS, I finally resorted to a combination of child and parent components as a last-ditch effort. This allowed me to place my modal outside the row -> col class structure.

It turns out that using a modal is not possible when a parent element has a display:flex property.

While not an ideal solution, it certainly gets the job done!

Answer №2

//webpack.config.js

located in the configuration

"./node_modules/react/dist/react.min.js",

"./node_modules/react-dom/dist/react-dom.min.js"

"./node_modules/react-router-dom/dist/react-router-dom.min.js"

included in index.html

@import "~bulma/css/bulma.css";

@import "~animate.css/animate.css";

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

Angular 2 does not recognize the existence of .then in type void

I have a query regarding Angular2 and I'm struggling with the void function in my code. Can someone help me out? I am new to Angular2 and unsure of what needs to be added in the void function. Check out this image for reference export class PasswordR ...

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 ...

Utilizing Google Maps within a responsive layout with 2 columns

Seeking guidance on integrating a map into the second column of a responsive website. Acknowledging that my code may not be optimal, as this is my first attempt at such a task. After a day of searching for solutions, I'm feeling quite desperate. HTML ...

Is there a way to remove the unwanted code ​ from the client side of my website?

Upon inspecting the source code of a webpage, I noticed an odd character ​ appearing before the <script> tag on the client side. Strangely, this mysterious character is not present anywhere in the server-side PHP file. I attempted removing a ...

Issue with JavaScript causing circles to form around a parent div

I am struggling to position a set of circles around a parent div in my code. I want 6 circles to form a circle around the parent div, but they are not lining up correctly. Can someone help me identify what I'm doing wrong? var div = 360 / 6; var ra ...

Having trouble triggering a dot MVC controller action method from an Angular service

Encountering the following Error: CORS policy block: Preflight request response access control check fails with HTTP ok status missing. Note: The ajax call successfully triggers the action method in other web applications, but an error is raised when usin ...

Centering text both vertically and horizontally over an image using CSS

I've been attempting to center the div banner_title both vertically and horizontally within another div in this way... .box { text-align: center; } .banner_title { font-size: 32px; position: absolute; top: 50%; width: 100%; } .banner_titl ...

Opacity filter malfunctioning

It seems that the filter: opacity property is not functioning as expected in IE8. Despite having used it successfully before, I am currently facing issues with its implementation. Strangely enough, Firebug does not display the filter rule at all; only norm ...

Inconsistencies found with CSS Dropdown Menu functionality across various web browsers

Issue Resolved - See Update Below While working on creating a CSS-only dropdown menu, I encountered an issue where the submenu would disappear when the mouse entered a small 3-4px section within the first item on the submenu. Even though this problem occu ...

Can someone help me understand why these checkboxes are not properly binding with the two-way binding, even though the opt.checked property is set to true?

<div style="display: table-caption" [id]="question.key" *ngSwitchCase="'checkbox'"> <div *ngFor="let opt of question.options; let i = index" style="display: flex; flex-directi ...

Incorporating an Aspx Page into a Static Website

We currently have a static website consisting of all html files. In addition, we have a dynamic ASPX website with a specific page (RegisterAndBuy.aspx) that displays data based on user selections and collects personal information to send to the Admin via ...

Issues with implementing Bootstrap collapse feature in Angular 9

Could use some assistance with my navbar as it's not opening the menu when screen size is changed. Current dependencies versions: "@angular/animations": "~9.0.6", "@angular/common": "~9.0.6", "@ang ...

Is there a variance in window.innerWidth between Chrome and Firefox?

body, html { position:absolute; width:100%; height:100%; margin: 0; padding: 0; overflow: hidden; } When using window.innerWidth, there is a discrepancy between the values returned by Firefox and Chrome. Firefox return ...

Determining the optimal time to utilize the addClass function in jQuery and CSS

One of my HTML elements has the class "article": <article> Content </article> In my jQuery script, I want to add specific classes that have been predefined: $('article').addClass('rounded box-shadow gradient-bright'); I ...

What is the best way to align elements in a div or navigation section?

Behold, my masterpiece navigation bar: #main-nav-bar .nav-item { display: inline-block; padding: 0.5%; border-right: 1px solid white; } #main-nav-bar a { text-decoration: none; color: #CFCFE0; } <nav id="main-nav-bar"> <a href="#Ser ...

Difficulty with collapsing icon in Bootstrap's navigation bar

I am in the process of building a bootstrap website and facing an issue with the collapsible navigation bar. The nav toggle button is always visible, but I want it to only appear when the nav bar goes to a medium size. How can I achieve this? The code sni ...

Is the XPath in Selenium executed against the Document Object Model (DOM) or the HTML file

Currently, I am in the process of developing a library for analyzing webpages. My approach involves using Selenium to access elements on a webpage through xpath. I have been contemplating replacing Selenium with an offline xpath tool. However, upon furthe ...

Setting the background color for a div in Vue.js when importing HTML

Check out this HTML code snippet <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Getting Started: Serving Web Content< ...

Ways to showcase various data on a single PHP page without relying on the GET method

I'm currently working on a project to create a website where users can set up their own profiles and share their profile link for others to view. Instead of having separate pages for each user, I want to streamline the process by using just one page t ...

Is there a way to select text using XPath based on the content of a preceding element

<div class="profile-details"> <div class="profile-info"> <h4 class="">Contact Number</h4> </div> <div class="profile-info"> <p class="">0207 289 2981</p> ...