I'm having trouble with one of my Bootstrap modals that just won't seem to work. I've tried troubleshooting

Currently, I am in the process of developing an application that can showcase multiple Bootstrap modals. At the moment, I have successfully implemented one modal for signing out, but unfortunately, the modal designed for displaying notifications is not functioning as intended.

The Bootstrap modal for signing out (works):

<div class="modal" id="NotificationModal" tabindex="-1" style="display:block;" role="dialog">
               <div class="modal-dialog">
                   <div class="modal-content text-center">
                       <div class="modal-body" style="background-color: rgba(64,0,64,0.95);">
                           <h4 style="color: white;">Are you sure you want to sign out?</h4>
                       </div>
                       <div class="modal-footer justify-content-center">
                           <button type="button" class="btn btn-modal" @onclick="@CloseNotificationModal">Yes, sign me out!</button>
                           <button type="button" id="SignOutModalClose" class="btn btn-modal" data-dismiss="modal" @onclick="@CloseNotificationModal">No, keep me signed in!</button>
                       </div>
                   </div>
               </div>
</div>

The bootstrap modal for showing notifications(designed to be full height on the right side) (does not work):

        <!-- Modal  -->
        <div class="modal right fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
            <div class="modal-dialog" role="document">
                <div class="modal-content">

                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel2">Right Sidebar</h4>
                    </div>

                    <div class="modal-body">
                        <p>Text</p>
                    </div>

                </div><!-- modal-content -->
            </div><!-- modal-dialog -->
        </div><!-- modal -->

In my quest to resolve this issue, I referred to a tutorial at: https://codepen.io/bootpen/pen/jbbaRa. I incorporated the HTML code into my container (similar to the placement of the other Bootstrap modal) and included the corresponding CSS in my bootstrap.min.css file.

If anyone could offer assistance, it would be greatly appreciated. I've been troubleshooting this problem for the past two days without success.

Sincerely, Niels

Answer №1

I encountered a similar issue. Make sure to inspect for any unclosed div tags within the modal.

Answer №2

CSS codes are necessary for this task.

.modal.right .modal-dialog {
  position: fixed;
  margin: auto;
  width: 320px;
  height: 100%;
  -webkit-transform: translate3d(0%, 0, 0);
  -ms-transform: translate3d(0%, 0, 0);
  -o-transform: translate3d(0%, 0, 0);
  transform: translate3d(0%, 0, 0);
}


.modal.right .modal-content {
  height: 100%;
  overflow-y: auto;
}

.modal.right .modal-body {
  padding: 15px 15px 80px;
}


/*Right*/

.modal.right.fade .modal-dialog {
  right: -320px;
  -webkit-transition: opacity 0.3s linear, right 0.3s ease-out;
  -moz-transition: opacity 0.3s linear, right 0.3s ease-out;
  -o-transition: opacity 0.3s linear, right 0.3s ease-out;
  transition: opacity 0.3s linear, right 0.3s ease-out;
}
/* change from fade.in to fade.show */   
.modal.right.fade.show .modal-dialog {
  right: 0;
}


/* ----- MODAL STYLE ----- */

.modal-content {
  border-radius: 0;
  border: none;
}

.modal-header {
  border-bottom-color: #EEEEEE;
  background-color: #FAFAFA;
}

.btn-demo {
  margin: 15px;
  padding: 10px 15px;
  border-radius: 0;
  font-size: 16px;
  background-color: #FFFFFF;
}

.btn-demo:focus {
  outline: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0c0dfc0c0d5c29edac3f0819e81869e80">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

<button type="button" class="btn btn-demo" data-toggle="modal" data-target="#myModal2">
Right Sidebar Modal
</button>

<!-- Modal  -->
<div class="modal right fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
  <div class="modal-dialog" role="document">
    <div class="modal-content">

      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel2">Right Sidebar</h4>
      </div>

      <div class="modal-body">
        <p>Text</p>
      </div>

    </div>
    <!-- modal-content -->
  </div>
  <!-- modal-dialog -->
</div>
<!-- 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 causes the content of my container to disappear following a setInterval div swap in Internet Explorer?

While developing a website on Chrome and Firefox, I was informed that it also needs to function properly in Internet Explorer. I managed to resolve the double padding issue in IE, but now I'm facing a new problem. The content of my "grid" disappears a ...

What is the method for setting an image to stretch and fill the divided screen?

I'm having trouble getting my image to fill the screen correctly on a split screen. The top half of the screen has an image, while the bottom half has text. No matter what I do, there always seems to be a blank space either at the top of the image or ...

What is the best way to expand/shrink elements smoothly when hovering with CSS?

As a beginner in the world of coding, I am eager to tackle something simple in CSS. My current project involves a landing page that is divided into two sections down the middle. The left side features a yellow div, while the right side showcases a grey div ...

Difficulty with Flexbox in Internet Explorer 11 when utilizing a Bootstrap .badge element

At the moment, I am dealing with a flex-row that contains an element that grows with the available space and a badge that should be aligned to the end without growing. However, when using flex-grow: 0 in IE11, the span.badge does not even take up the width ...

What is the best way to align an image in the middle of an image slider within a Bootstrap

Struggling to align the image properly in a Bootstrap 5 image slider carousel: https://i.sstatic.net/upPza.png <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel"> <div class=&qu ...

Bootstrap 4 does not have the capability to include spacing between two columns

I'm encountering an issue with adding a gutter between 2 columns on my website layout. I have a row that needs to be 1280px wide (based on a reference resolution of 1366x768 with padding of 43px on each side of the page), containing two sections that ...

Tips for initiating a scrollable (overflow-y: scroll) div in the middle rather than the top while scrolling

I am working on a code where I have a scrollable div with overflow-y: scroll. However, the default scrolling starts at the top of my div when I want it to start in the middle. Can anyone suggest a solution for this issue? export function Portfolio({ chi ...

How come my countdown application functions properly when accessed through the browser via the HTML page, but encounters issues when utilized with an HTTP server?

I have encountered an issue where the app functions correctly when I open the HTML file in my browser, but fails to load the CSS and JavaScript when accessing it through localhost:3000. HTML: <html> <head> <link href="./main.css" rel="st ...

Dynamic search bar in Javascript showing empty spaces for cards that are not currently visible

Currently, I am in the process of developing an online learning platform which features a catalog of courses. Users can search for courses based on the titles or descriptions using the search bar. To display the catalog, I have utilized bootstrap cards. Th ...

"Enhancing web design with jQuery mousemove to dynamically adjust CSS filters according to mouse location

I'm attempting to create a simple mousemove event that changes the CSS filter property of my background div based on the position of the mouse. While I have successfully achieved this in the past with background-color, I am now encountering issues wit ...

Prevent the display of cascading div elements by using JavaScript and jQuery scripting

My webpage performs a simple check to verify if Javascript and cookies are enabled on the client's browser. If they are enabled, the script displays the content inside div id="conteudo" and hides the warning message inside div id="aviso". If not, the ...

Leveraging the power of HTML5's details element for optimized printing

The <details> HTML5 element is used to provide a simple show/hide functionality. While this feature works well on-screen, it poses an issue when printing as any closed <details> elements disappear in the printed version. I attempted to fix th ...

Adjusting the spacing between the logo and navbar in HTML code

I am struggling to understand why this issue keeps occurring: I have thoroughly checked for errors, attempted multiple solutions, yet the problem persists. Please assist body { margin: 0; padding: 0; } .logo { margin: 0; padding: 0; } ul { li ...

Arrange and display similar objects together

I have a list of items in a listView that need to be visually grouped based on their class, displayed within boxes. For example, I have 5 items with the following classes: <div class="1"></div> <div class="1"></div> <div class= ...

Attempting to create a div element that automatically adjusts itself horizontally in the center through the utilization of margins

I searched through examples on stack overflow that had similar problems to mine, but unfortunately, I couldn't find a solution. I'm not sure what I'm doing wrong, but the div is not aligning horizontally center as expected. It seems to work ...

React not displaying images with relative paths

In the past, I used to import images in React like this: import person from '../images/image1.png' And then use them in my code like this: <img src={person} alt="" /> Now, for some reason, I want to directly specify the image pa ...

Tips and instructions for assisting IE6

What are some important tips and guidelines to consider when designing websites that need to be compatible with Internet Explorer 6? I'm not interested in a detailed list of known bugs. I want general advice on preferred elements for certain tasks, f ...

What is the best way to divide the background into two distinct colors behind an image by utilizing bootstrap?

Can someone help me with this in bootstrap? I'm attempting to accomplish the following. Thanks in advance! Here are the codes I have so far: <body> <nav class="navbar navbar-expand-lg navbar-light"> <div class=&qu ...

Alter the design when the height of a div is adjusted

On my webpage, I have multiple divs displayed in a masonry layout. The masonry effect works smoothly, but I am facing an issue with the divs expanding in height when users leave comments. The masonry layout does not automatically adjust to accommodate the ...

Determine the dimensions of a div element in IE after adjusting its height to auto

I am currently working on a JavaScript function that modifies the size of certain content. In order to accomplish this, I need to obtain the height of a specific div element within my content structure. Below is an example of the HTML code I am dealing wit ...