Using table-responsive causes a modal to break inside because of overflow-scrolling touch in the CSS

When implementing a modal within a table that is inside a table-responsive container, the modal appears behind the table.

To address this issue, I have tried using table-backdrop="false", but it is not an ideal solution as it restricts the full functionality of the modal. Altering the bootstrap CSS also provides a temporary fix, but I am seeking a foolproof bootstrap method without any customization to resolve this problem.

The root cause: The problem can be resolved by applying overflow-x: auto;, but this hinders smooth scrolling on mobile devices. However, adding -webkit-overflow-scroll: touch enables smooth scrolling, but it results in the same issue as with table-responsive

Example:

<div class="table-responsive"> //this causes the issues
  <table class="table align-items-center">
    <thead>
      <tr>
        <th scope="col"></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <th></th>
      </tr>
    </tfoot>

    <tbody class="list">
        <tr>
          <td>
            <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#exampleModal">
              View Order
            </button>

            <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
              <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Order</h5>

                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                  </div>

                  <div class="modal-body">
                    <div class="table-responsive">
                      <table class="table">
                       ...
                      </table>
                    </div>
                  </div>

                  <div class="modal-footer">
                  </div>
                </div>
              </div>
            </div>

          </td>
        </tr>
    </tbody>
  </table>

</div>

The modal will appear grayed out and unclickable or unable to close. Removing table-responsive from the first table (top div class) allows it to function correctly. By manually applying

overflow-x: auto; -webkit-overflow-scroll: touch
, it breaks in the same way.

It's essential for the modal to stay in the current location as the information displayed depends on the loop from the table.

Is there a workaround for this issue? Mobile responsiveness of the table is crucial.

I aim to have a responsive table with smooth scrolling capabilities.

Answer №1

Hello there, have you considered placing the modal outside of the table-responsive container?

Answer №2

The problem arises when working with turbolinks and incorporating forms into tables.

Instead of completely turning off turbolinks, I opt to disable them only on the specific page with my link_to button.

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

Is one round the limit for my JavaScript image slider?

After studying the JavaScript Chapter on W3Schools, I attempted to create an image slider. Initially, everything worked perfectly for the first cycle. For instance, when I clicked the next button, the slides continued to slide until the end of the slidesho ...

Mpdf does not support inline CSS rendering

I recently implemented Mpdf into my Symfony project using Composer. The installation process involved running the following command: composer require mpdf/mpdf Next, I included the Mpdf.php file in autoload.php. Here is an example of how to use Mpdf in ...

Use jQuery to transition the "position:absolute" element from top to bottom and create a smooth fade effect

When the "anim" class is activated, it should smoothly fade in from top to bottom Here is the corresponding HTML code: <div class="col-xs-6" style="position:relative;"> <img src="<?= site_url('assets/image/right_bg.png'); ?>" ...

What is the best way to arrange these elements and a sidebar to achieve this specific layout?

Need help aligning items in CSS to achieve this layout using flexbox. Thank you. | Text A | text B | text C | video | | text d | text E | text F | video | The video is the same in both rows and should extend along the side as a sidebar. ...

Bootstrap carousel slide animation isn't transitioning properly

I am encountering an issue with my carousel animation. I am aiming for a slide-out/slide-in effect similar to the Bootstrap website, but instead of sliding out, the old item simply disappears and the new item slides in. I have included a GIF to illustrat ...

Perform a check on the state of the slideToggle using an if-else function and provide a report on the slideToggle state

http://jsfiddle.net/vmKVS/ I need some help understanding the functionality of slideToggle using a small example. After toggling for the first time, the options element changes color to green. However, I expected the menu element to turn red when I togg ...

Creating interactive and adaptable maps

Currently, I am working on making a Joomla website responsive. However, I have encountered an issue with the SobiPro Map. The problem arises when displaying a map (background img) and points (a link + img) over it with an absolute position. As a result, wh ...

The Battle of Priority: Conflicting !Important Declarations in CSS

I'm currently revamping a CSS template created by previous developers. I've noticed that a specific block is duplicated, with one version hidden for wide-screen display and the other hidden for smaller screens. It's unclear why two separate ...

Is there a way to place two input fields from different forms side by side on the same line?

Here are two forms extracted from an html page: <form method="get" action="search/s" id="number"> <div style="text-align: center;"> <input type="text" id="regNo" name="regNo" size="30" maxLength="50" > or ...

The previously set display value remains unchanged when switching CSS files

I'm working on a project where I need to display three separate articles based on the screen size. Article 1 should only be visible when the screen width is less than 600 pixels Article 2 should be visible between 600 and 900 pixels Article 3 shoul ...

Utilizing Stylus: Embracing Interpolation within a Mixin

I am encountering an issue while attempting to interpolate values passed into a mixin. positionModifier( key, x, y) &.{key} background-position: {x}px {y}px; An error is being thrown, which is shown below: 351| positionModifie ...

NgTemplate Bootstrap is not recognizing my CSS class

I made a CSS adjustment to alter the modal width to 50% instead of 100% of the screen. However, the class modal-content is being duplicated after the modification. https://i.sstatic.net/VZxM6.png https://i.sstatic.net/ahLkn.png CSS .modal-content{ ...

encountered net::ERR_EMPTY_RESPONSE while attempting to locate a CSS file within an AngularJS directive

Every time my webpage attempts to access the css file from a directive, I encounter a net::ERR_EMPTY_RESPONSE. I have implemented door3's on-demand css feature, which allows for lazy loading of css files only when necessary. This feature works flawle ...

Experiencing an issue with excess right padding when utilizing Bootstrap 4.5 cards

I am attempting to implement this specific bootstrap 4.5 card layout in my react application, but I am encountering the following two problems: All three cards in the deck have an additional right padding of 44px. The card header is lacking a complete bor ...

Enlargement animation when hovering over a "next-link" button featuring an SVG file of a social media platform

The following code snippet demonstrates how to import an Instagram icon and create a footer component: import InstagramIcon from './assets/IG.svg'; export const Footer = ({ footer }: FooterInterface) => { return ( ..... <Link href={`${fo ...

A feature in Rails allowing users to favorite posts using Ajax technology

Currently, I am working on displaying user posts with nested resources and have compiled a lengthy list of posts from various users. My goal is to allow users to click a small star icon next to each post in order to favorite it using ajax. Do you have any ...

How to align a div in the center while another div is floated to the right?

Shown below is an example: <div id="mainContainer"> <div id="itemIWantToCenter"></div> <div id="itemIwantFloatedRight"></div> </div> The mainContainerwidth width is set to 100%. The itemIwantFloatedRight widt ...

Overlapping Divs - HTML Elements Crossing Paths

My challenge is to position the Social Icons at the bottom of the screen and align the Image Gallery in the middle. However, the social Icons keep moving to the center of the screen and the Image gallery ends up overlapping them, making it difficult for me ...

Show me how to customize the default confirmation box using just CSS!

Is it possible to style the standard window.confirm using only CSS without any additional JavaScript code? If so, how can this be achieved? ...

Change a div to scroll vertically instead of expanding to accommodate its content

I am facing an issue with the layout I have created. It consists of a scrollable list of items in the center, with additional content above and below it in a column. The challenge is to make the list occupy all available empty space within the column witho ...