Bootstrap collapsibles inline position

I am currently utilizing bootstrap in my project and facing an issue with collapsibles. I want them to be displayed on the same line, but when I expand the first one, the second collapsible moves down into the space of the first one.

Check out this screenshot

Here is how I have structured my two collapsibles:

  <div class="row">
    <div class="container">
      <h2>Nerve Cuffs</h2>
      <hr>
      <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#2-Channel">2-Channel Nerve Cuffs <i class="fas fa-angle-down"></i></button>
      <div id="2-Channel" class="collapse">
      <div class="row">
        <div class="col-6">
          <h4>NC-630-2</h4>
        </div>

      </div>
      <h5><span class="badge badge-secondary">2-Channel</span></h5>
      <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#1">Specifications <i class="fas fa-angle-down"></i></button>
      <div id="1" class="collapse">
      <p>Electrode Length: 0.630mm <br>
         Electrode Width: 0.150m <br>
         Electrode Area: 0.095 mm<sup>2</sup> <br>
         Electrode Sites: 2 <br>
         Electrode Spacing: 1.000m 
        </p>
      <p>Device Length: 5.000m <br>
         Device Width: 2.00mm <br>
         Device Thickness: 30 ± 5 μm   
        </p>
      <p>
        Standard Electrode Material: TiN <br>
        Connector Options: Bare wires, Plastics One, Omnetics  
        </p>    
        </div>>
        
        ...
        
        <p>Standard Electrode Material: TiN <br>
        Connector Options: Bar...
        

     </div>
      </div>              
    </div>

If anyone has any suggestions or solutions, I would greatly appreciate it!

Answer №1

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">
      <h2>Nerve Cuffs</h2>
      <hr>
      <div class="row">
          <div class="col">
              <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#2-Channel">2-Channel Nerve Cuffs <i class="fas fa-angle-down"></i></button>
            </div>
            <div class="col">
                 <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#4-Channel">4-Channel Nerve Cuffs <i class="fas fa-angle-down"></i></button>
                </div>
     

    </div>        
      
     
    </div>;
    
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

utilizing the bootstrap column feature can resolve your issue. Make sure to wrap the contents of each button in a row with columns.

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

Responsive mode causing navbar to break

After creating my web portfolio, I encountered an issue when viewing it on my phone. The navbar collapses but is not properly aligned and there is extra space on the right side of the viewport in the hero section that I can't seem to fix. Portfolio L ...

A series of 8 columns lined up neatly in Bootstrap 4

In need of a row with 8 columns on a large device and fewer columns on a smaller device. Bootstrap's 12-grid system only offers predefined classes like col-1, col-2, col-3, col-4, col-6, and col-12, making it impossible to have a row with exactly 8 c ...

How come I am unable to alter the container padding variable within BootstrapVue?

I am currently in the process of developing a BootstrapVue 2.0 theme that is based on Bootstrap 4.3, following the guidance provided by the VueBootstrap theming guide. Inside my theme.scss file, I have included my custom overrides at the beginning and impo ...

Tips for swapping out a JavaScript variable for a JSON file

I'm currently in the process of developing a website and I'm relatively new to website coding. My aim is to have a rotating text feature that switches between words, similar to a splash text seen in games like Minecraft. I understand that it woul ...

What is the best way to update or include a new class in the jQuery mobile loader widget?

After reviewing the documentation at this link: I discovered a method to modify or add the default class of the loader widget, ui-loader. Despite my attempts, I have not been able to see any changes. You can view my demo here: https://jsfiddle.net/yusril ...

What is the best method for aligning forms vertically within a page layout?

I'm working on designing a contact form, but I'm having trouble getting everything to align properly. Specifically, I can't seem to get the form elements to line up vertically and I also want the Message label to appear on the top left side ...

jquery not responsive to font-size changes in textarea during screen resize

JavaScript Code $(window).on('resize', function(){ if ($(window).width() <= 800) { $('textarea').css("font-size", "20x"); } else { $('textarea').css("font-size", "30x"); } }); View Demo I a ...

Using jQuery to apply both class and font styles to HTML elements and then returning the modified HTML

I have received HTML text that requires the addition of a Bootstrap class after identifying specific tags. The string may contain multiple tags, and I need to insert a font tag with importance. For example, suppose I have the following string: var temp = ...

Transform cursor with jQuery on hover and click events

Currently, I'm implementing an image zoom feature, and I want to incorporate two different mouse states for hover actions. #1 Upon hovering over the containing <div>, the cursor should change to a 'plus' symbol. #2 Once the user cl ...

Enhance the code for updating the content within a div element

I recently discovered that utilizing jQuery allows for updating the content within a div. My goal now is to enhance this script so the content remains consistent, even while loading or not. Take a look at my current code: function changeContent () { va ...

Why is the HTML5 audio player only playing the first two songs in the array?

Why do only the first 2 songs play and then nothing happens? I want them to keep playing through the entire array of songs. Additionally, my rewind button is not working as expected - when clicked, it should go back to the previous song in the array and if ...

Encountering an issue with usememo in React js?

I'm currently experimenting with the useMemo hook in React JS. The goal is to sort an array of strings within a function. However, when I return the array from the function, only the first element is being returned. Can someone please assist me in ide ...

Utilizing Consistent Styles Across Multiple Components within an Angular 2 Application

In my Angular 2 app, I have some CSS rules that are shared among multiple components. I don't want to duplicate these rules in each component's styles. Currently, I am considering two approaches: Storing common CSS rules in a static CSS file an ...

What causes Chrome Extension Images to appear broken when they are inserted into the DOM?

Currently working on a Chrome extension, I am attempting to insert a div with a background image into the DOM using a content script. The CSS is loading correctly, and upon inspecting the Developer Tools, the image URL appears to be correct. $('.clos ...

What is the best method for incorporating meta data, titles, and other information at dynamic pages using Node.js and Express?

I am currently exploring methods to efficiently pass data to the html head of my project. I require a custom title, meta description, and other elements for each page within my website. Upon initial thought, one method that comes to mind is passing the da ...

I am trying to confirm in PHP whether any of the gender checkboxes have been selected. However, the code I have tried so far does not appear to be functioning as expected

Please refrain from suggesting the use of checked = "checked" in HTML, as the validation must be performed in PHP as per the requirements of my assignment. PHP Code: if (isset($_POST["gender"])) { $gender = $_POST["gender"]; if (($gender != "male") || ( ...

How to Modify the Top Position of an Element using uBlock Origin

In my efforts to reposition the main text of this website (), I am looking to move it from the middle to the top. The code for the section is <div id="content_blaettern_12793">. The current CSS styling has it fixed in place: #content_blaet ...

Exploring an HTML document with XPath expressions

I am trying to query an HTML document using C# and XPath. I am specifically looking for an XPath expression, without any language-specific code samples like XSLT or PHP. Any assistance with providing the XPath expression would be greatly appreciated :). & ...

File.type cannot be obtained in IE 11 and IE Edge due to compatibility issues

"change .btn-file :file" : "getfileinfo", getfileinfo: function(e){ var fileInput = document.getElementById('fileupload'); var file = fileInput.files[0]; if(!file || (file.type != 'text/plain' && file.type != ' ...

Discrepancies in Flexbox Handling of Images between Chrome and Firefox

My goal is to showcase images on a flexbox grid, and while it works perfectly in Chrome, I'm encountering issues in Firefox (uncertain where the problem lies). Check out the CodePen link for reference : https://codepen.io/anon/pen/QJNajw?editors=1100 ...