The Bootstrap collapsible feature is causing elements to shift to the adjacent column

I'm currently implementing bootstrap's collapsible feature to showcase a list of stores along with expandable details.

However, the issue arises when I expand one of the collapsibles in the left column, causing certain items to shift into the next column. On the other hand, expanding a collapsible in the right column results in a proper sliding animation but introduces additional space in the left column. To witness these two behaviors, please visit the following Plunker link and resize the screen until there are two rows of collapsibles: http://plnkr.co/edit/2SLCQQJetyvM34mrCsHj?p=preview

Below is the code snippet I am using:

<div class="panel panel-default store-wrapper">
  <div class="panel-heading">
    <h4 class="panel-title">
      <a data-toggle="collapse" data-target="{{removeSpaces(x.name, true)}}">
        {{x.name}}
      </a>
    </h4>
  </div>
  <div id="{{removeSpaces(x.name, false)}}" class="panel-collapse collapse">
    <div class="panel-body">
      <div class="store-info col-xs-12 col-sm-12 col-md-6 col-lg-6" ng-repeat="item in x.stores">
        <div class="col-xs-6 city">{{item.city}}:</div>
        <div class="col-xs-6 phone">
          <a ng-href="tel:{{item.number}}">{{item.number}}</a>
        </div>
      </div>
    </div>
  </div>
</div>

My objective is to ensure that when a collapsible is expanded, only its corresponding column slides without affecting neighboring items or shifting onto the next row. Is it feasible to achieve this within Bootstrap's grid system?

Answer №1

If you're looking for a quick fix, here's one solution that might work for you.

All you need to do is insert

<div style="clear:both"></div>
after every two occurrences of the col-xs-12 div element. This should prevent any elements from getting pushed to the right unexpectedly.

You can take a look at an example of this in action here.

Keep in mind: Make sure to include the clear div after every N collapsible divs (where N corresponds to the number of columns).

Answer №2

Consider utilizing two separate columns for organizing your panels, like this:

<div class="container">
  <div class="row">
    <div class="col-sm-6">
      <div class="panel panel-default store-wrapper">
        <div class="panel-heading">
          <h4 class="panel-title">
            <a data-toggle="collapse" data-target="#xname-1">
              xname-1
            </a>
          </h4>
        </div>
       ...
</body>

UPD. I've updated my Plinker to remove unnecessary redundancies. Please note that my familiarity with Angular is limited.

http://plnkr.co/edit/Hj0NF9Vb5ydNIrXLOwPT?p=preview

<body ng-controller="MainCtrl">
  <div class="container">
    <div class="row">
      <div class="col-xs-12 col-sm-6" ng-repeat="column in [0,1]">
        <div class="panel-group col-xs-12 stores-container" ng-repeat="x in storeList" ng-if="$index >= ( $parent.$index * storeList.length / 2 ) && $index < ( ( $parent.$index + 1 ) * storeList.length / 2 )">
          <div class="panel panel-default store-wrapper">
            <div class="panel-heading" data-toggle="collapse" data-target="{{removeSpaces(x.name, true)}}">
              <h4 class="panel-title">
                  <a>
                    {{x.name}}
                  </a>
                </h4>
            </div>
            ...
</body>

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

Interested in learning how to utilize tabs for a carousel?

Instead of relying on third party libraries for a carousel on our site, I'm considering using Md-tabs which have similar features, including swipe gestures. It seems like setting a time interval between tabs could be achievable. The functionality shou ...

Utilize the splice function when resizing the window based on specific breakpoints

On a series of div elements, I have implemented some JS/jQuery code that organizes them by wrapping every three elements in a container with the class .each-row. <div class="element"></div> <div class="element"></div> <div class ...

Customize the size of data points on your Angular 2 chart with variable

In my Angular 2 application, I am utilizing ng2-charts to create a line chart. The chart functions properly, showing a change in color when hovering over a point with the mouse. However, I want to replicate this behavior manually through code. Upon clicki ...

implementing a sidebar menu using AngularJS

I am currently working with bootstrap and AngularJS to create a sidebar menu. Here is the code I have for it: <ul class="nav navbar-nav"> <li><a href="#"><span class="glyphicon glyphicon-send"></span> Link</a& ...

CSS: The Drop Down menu suddenly vanishes every time I attempt to select an item from the visible list

I'm facing an issue with my dropdown menu that I can't seem to resolve. Whenever I hover over the menu, it disappears before I can even click on any items. <ul id="menu"> <li><a href="#title">Home</a></li> ...

Is the container in semantic ui being breached by a segment overflow?

I've recently started learning Semantic UI. One issue I'm facing is that the width of the "segment" overflows the "container." Check this JSFiddle for more clarity. Are there any alternative solutions? In addition to the grid system, I'm ...

Is it possible for Angular.js timer finish event not to trigger data binding correctly?

I've been working on an AngularJS application that functions as a quiz by displaying pictures and prompting users to select the correct answer by clicking a button. The app is designed to store the user's answers in an object. Everything seems t ...

Can you explain the purpose of :not(style) ~ :not(style) in CSS?

Upon investigating, I found that Mui automatically included a :not(style) ~ :not(style) selector which required the use of !important in my sx to override. .css-1rb8ayf-MuiStack-root > :not(style) ~ :not(style) { margin-top: 40px; } .css-d13d9m-MuiSta ...

Determine the Height of the Container once the Font File has Finished Loading

When styling a website with a unique font using @font-face, the browser must download the font file before it can display the text correctly, similar to how it downloads CSS and JavaScript files. This poses an issue in Chrome (v16.0.912.63) and Safari (v5 ...

Implement the AngularJS orderby filter based on a checkbox selection

Is it possible to use the angularJS orderby filter with a checkbox for ordering columns? I currently have this working as expected: <tr ng-repeat="player in players | orderBy:'id':true | rangeFilter:min:max"> <td>{{player.id}}</ ...

The proper translation of the HTML encoded string is not being rendered accurately within AngularJS

I am dealing with an HTML encoded string that looks like this: Sign up and get &lt;span class=&quot;strong&quot;&gt;Something for FREE!&lt;/span&gt; When I implement ngSanitize and ng-bind-html in my template as shown below: ...

Centered horizontally are images that have been floated

How can I align images with different widths when they are all floated right? I want them to be aligned vertically below each other. For the best display, please view in fullscreen on your computer as the example window is small. .compressor{ height: 1 ...

What is the best way to dynamically assign a value to ng-model using a template URL?

Recently, I started learning AngularJS and decided to create a directive that would load a template URL and allow me to change the ng-model value. Unfortunately, I encountered an issue where the value was not changing as expected. I attempted to replicate ...

Unable to locate the hidden element

Attempt to access the attribute of a shadow element resulted in encountering ElementNotVisibleException Element with CSS input[type='checkbox'] is not present on screen <checkbox _ngcontent-ebv-c14="" label="User Access" ng ...

Fine-tuning the flexbox grid layout for various screen sizes, both big and small

Two different layouts were created. The first layout is designed for medium & large screens, while the second one is tailored for devices with a maximum width of 736px. Check out the vanilla implementation using flexbox (without mobile adaptation) Here ...

A guide on expanding an HTML table dynamically with MVC razor syntax

My goal is to dynamically add new rows to a table by following the advice given in this answer on Stack Overflow: Add table row in jQuery I have successfully implemented it for one of my table requirements as seen below: function onAddItem() { $( ...

Adjusting the properties of a <span> tag when hovering over a different element

Query: I am trying to dynamically change the color of the span element with classes glyphicon and glyphicon-play when the user hovers over the entire element. How can I achieve this? Recommendation: .whole:hover > span.glyphicon.glyphicon-play { c ...

AngularJS table with resizable columns for seamless data browsing

Most examples of expandable tables using ng-repeat feature a separate content for the expanded row, like an independent table inside the detail row. I have implemented many expandable tables using these methods, similar to the following: <tr ng-repeat ...

``There seems to be an issue with implementing the SlideDown feature in JavaScript

I am having an issue with a code where the expected behavior is to slide down a div when a person hovers over text, but it's not working. Can someone please review and identify the cause of this problem? <script type="text/javascript" src="/js/jqu ...

Creating Angular Custom Form Validation and Custom Directives

I recently created a custom validation directive and applied it to the form element like this: <form myValidations> app.directive('myValidations', function(){ return{ //require: 'ngModel', note its commented out link: f ...