Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap modal overflowing my table row

See http://jsfiddle.net/9sjRh/

I have table in a modal but it is overflowing. I have playing css tricks with it such as changing the width of the modal or changing the margins. None of these seems to have worked. Any help would be appreciated.

HTML

<div id="classModal" class="modal fade bs-example-modal-lg" tabindex="-1"
    role="dialog" aria-labelledby="classInfo" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
              ×
            </button>
            <h4 class="modal-title" id="classModalLabel">
              Class Info
            </h4>
          </div>
          <div class="modal-body">
            <table id="classTable" class="table table-bordered">
              <thead>
              </thead>
              <tbody>
                <tr>
                  <td>CLN</td>
                  <td>Last Updated Date</td>
                  <td>Class Name</td>
                  <td># Tests</td>
                  <td>Test Coverage (Instruction)</td>
                  <td>Test Coverage (Complexity)</td>
                  <td>Complex Covered</td>
                  <td>Complex Total</td>
                  <td>Category</td>
                </tr>
              </tbody>
            </table>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal">
              Close
            </button>
          </div>
        </div>
      </div>
    </div>

JS

$('#classModal').modal('show')
like image 1000
skalidindi Avatar asked May 07 '14 05:05

skalidindi


People also ask

How do I change modal content width?

Modal Size Change the size of the modal by adding the . modal-sm class for small modals, . modal-lg class for large modals, or . modal-xl for extra large modals.

Is bootstrap modal responsive?

Bootstrap 5 Modal component. Responsive popup window with Bootstrap 5. Examples of with image, modal position i.e. center, z-index usage, modal fade animation, backdrop usage, modal size & more. Modal is a responsive popup used to display extra content.

How do I enable scrolling in modal?

Use the . modal-dialog-scrollable class to enable scrolling inside the modal.

How do I get data from modal popup?

Data can be passed to the modal body from the HTML document which gets displayed when the modal pops up. To pass data into the modal body jquery methods are used. jQuery is similar to JavaScript, however jQuery methods are simple and easier to implement. jQuery reduces the lines of code.


2 Answers

I am not sure if the issue is resolved or not but my solution is :

Append the below written CSS tag into your fiddle and get the thing done.

.modal-body {
  overflow-x: auto;
}

You can find my JSFiddle here.

like image 168
b0y Avatar answered Nov 15 '22 12:11

b0y


I know its too late but this is what worked for me

Wrapped the table inside a div and added overflow:auto as a style

<div style="overflow: auto">
       <table class="table table-hover">

            <thead>
                <tr >
                   <th id="th1">Header 1</th>
                   <th id="th2">Header 2</th>
                </tr>
            </thead>

             <tbody>

             </tbody>

          </table>
</div>
like image 43
Nikhil Das Nomula Avatar answered Nov 15 '22 13:11

Nikhil Das Nomula