What causes the columns in my table to move when a Bootstrap collapse is activated?

Utilizing Bootstrap's collapse feature, I want to create an expanding table row that reveals more details.

When the row is clicked, the other columns seem to move slightly. It appears that this is somehow related to the length of the details, but I haven't been able to find a way around it.

<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 shift when clicked</td>
      <td>I'm second </td>
      <td>I'm 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 observe the issue in action in this Bootply example: https://www.bootply.com/HJfNNB5CPs

Watch closely as you click the red text to see how the other columns behave.

Answer №1

I'm puzzled by the occurrence of this issue, but it appears to be resolved when you explicitly define the width of the td that holds the collapsible element.

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

Check out the updated bootply here

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

Change the opacity of a DIV or any other element when hovering over it

I have successfully applied opacity: 1; to a paragraph when hovering over itself. However, I want the opacity to also change when hovering over the header above it. Here is my CSS code: .testH { font-family: impact; text-align: center; font-s ...

Tips for utilizing sorting, searching, and pagination features in Bootstrap 5 tables

In my simple table, https://i.sstatic.net/bu1md.png Furthermore, I have integrated Bootstrap 5: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="15777a ...

What is causing the issue with the "Inline-block" property in this CSS code?

Please review the CSS code provided below for styling instructions. /*rex is the container of ex,ex2,ex3*/ div.rex{ height:200px; border:0px; margin:60px auto; padding: 0; vertical-align:top; } div.ex{ width:34%; height:200px; background-color:#4f443a; ...

Learn how to add the SASS version of Bootstrap to your project using NPM without including the JavaScript files

Currently, I am undertaking a project that requires the use of Bootstrap's CSS via Sass, without the need for JavaScript. Although including bootstrap-sass through NPM is not an issue, all the unnecessary JS files are causing clutter as they serve no ...

Using PHP, dynamic webpage content is displayed on top of a Navigation Bar

I needed a Navigation Bar that would be consistent across all webpages, so I decided to create a file called Header.html and use <?php include('Includes/Header.html') ?> in all of my webpages to easily add the Navbar/Header to the top of ea ...

Adjusting grids in Bootstrap according to device orientation

I have a vision for a webpage layout that will feature two columns in landscape mode and switch to one column in portrait mode. Here is an outline of what I have in mind: Landscape: <body> <div class="container-fluid"> <div cl ...

Show images exclusively on screens with a smaller resolution

Looking for assistance in modifying the code below to only display the image in mobile view, instead of constantly appearing. <style type="text/javascript> .icon-xyz {float: left; width: 22px;cursor: pointer;background: none;} @me ...

Best approach for adding an image to an HTML help button: which semantic option is most effective?

Is there a way to create an HTML help button that appears as an image? What would be the most appropriate and semantic approach to achieve this? Below are three different solutions I have considered: 1st idea: Using HTML <button class='help&ap ...

Adjust the image size in the jumbotron to fit perfectly without the need for scrolling

I'm in the process of creating a website with a prominent jumbotron section on the landing page. I am looking to adjust the height of the image within the jumbotron without cutting off any parts of the picture, and I do not want it to scroll to displa ...

Utilize HTML to resize image to fit within container

I've encountered an issue while working with Adobe Dreamweaver CS5. I added a swap behavior to an image in an html document, expecting it to pop up at its original size and restore on mouse out. However, the swapped image ends up filling the entire sc ...

Injected code from a self-built extension may not be applied by Google Chrome on certain websites until the scroll wheel is turned

I have developed two unique Chrome extensions designed to enhance web pages with CSS and SVG filters. Here are the links to the source code: CB Enhancer (adjusts colors for color-blind users) https://drive.google.com/open?id=1hvJIn3kPAMjaIWrAiUtIEVkEesQ1c ...

Is it possible to change the tab to "home-tab" by clicking on navbar-brand in Bootstrap 5 using JavaScript?

This is my first venture into web development, so please bear with me as I navigate through this unfamiliar territory. In my project, I have a function called Navbar() that generates a navigation bar on the webpage by wrapping all elements with the navbar ...

Increase the spacing within div columns containing rows of uniform height

Is there a way to add some extra space between the H3-1 div and the H3-2 div? Ideally, I would like to achieve this without using custom CSS, but if necessary, that's okay too. I'd prefer to stick with the col-sm-6 class instead of using col-sm ...

Delegating events with .on('click') and using the CSS negation selector :not()

Struggling to implement event delegation for a dynamically added or removed class? I need to create an event for elements that are clicked, but without a specific class. Here's the code I have so far, but it doesn't seem to be working. Could it b ...

How can I ensure a div expands over another element when hovering the mouse?

I have a development div in the footer with a hover effect that expands it. However, it is currently growing underneath the top element on the site. I want it to expand on top or push the element above. Website: I've tried using position, float, and ...

Make the text area occupy the full width of the remaining screen space

I've been struggling to make the text area fill the remaining width of the screen. Everything is set up nicely, but I just can't seem to find a solution to get it to expand and occupy the rest of the available space. I intentionally refrained fr ...

How can I extract particular combinations from a PHP array?

I have a unique question that is quite specific and despite searching online, I couldn't find an answer. So, I decided to seek advice here. Imagine my webpage has three sliders: one for selecting color options for a square, another for a circle, and ...

Issue with Bootstrap 4 Navigation Displaying Incorrectly with Values in Navigation

Issues with displaying navigation properly when populated with values. Seeking a solution, can anyone help? https://i.sstatic.net/P3GG8.png <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity ...

What is the best way to ensure a jQuery function runs on duplicated elements?

I have been attempting to construct a webpage featuring cascading dropdowns using jQuery. The goal is to generate a duplicate set of dropdowns when the last dropdown in the current set is altered. I aim for this process to repeat up to 10 times, but I cons ...

What is the best way to configure custom CSS styles in a React project?

I've been trying to position my Grid component from Material-UI, but so far, I haven't had any luck. What could be the issue here? class Scene extends React.Component { render() { const mystyle = { backgroundColor: "DodgerBlue", ...