Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do my table's columns shift when a Bootstrap collapse is triggered?

Using bootstrap's collapse feature, I would like to get a table's row to expand and reveal more details.

when a row is clicked, the other columns, for some reason, get a slight movement. This seems to have something to do with the LENGTH of the details but I could not figure out a bypass.

<table class="table">
  <thead>
    <tr>
      <td>title 1</td>
      <td>title 2</td>
      <td>title 3</td>
    </tr></thead>
  <tbody>
    <tr>
      <td data-toggle="collapse" href="#rowID">other columns move when you click me</td>
      <td>im second </td>
      <td>im third</td>
    </tr>
    <tr>
      <td colspan="3">
        <div class="collapse" id="rowID">
          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>           
        </div>
      </td>
    </tr>
  </tbody>
</table>

you can see the issue in this bootply example: https://www.bootply.com/HJfNNB5CPs

focus your eye on the other columns as you click the red text.

like image 591
Stavm Avatar asked Dec 22 '25 10:12

Stavm


1 Answers

I'm not sure why this is happening but it seems to resolve if you explicitly set the width of the td containing the collapsable element.

td[colspan="3"] {
  width: 100%;
}

updated bootply

like image 142
sol Avatar answered Dec 24 '25 02:12

sol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!