Why does the Bootstrap heading momentarily collapse before quickly reappearing?

Just starting out with HTML, CSS, and Bootstrap, but struggling with getting collapse to function properly.

I've attached a gif demonstrating the issue I'm facing. While using bootstrap, collapse on an H4 tag is not working as expected. Can't figure out what's going wrong. Any assistance would be greatly appreciated.

Check out the GIF

Highlighted below is my code snippet:

.jumbotron {
  background-color: #2E2D88;
  color: white;
}

/* Adds borders for tabs */
.tab-content {
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 10px;
}
.nav-tabs {
  margin-bottom: 0;
}
<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 Tutorial</title>
  <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 1</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 2</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 3</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 4</h4>
        <p>Lorem ipsum</p>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4><a href="#col1content" data-toggle="collapse">Column 1</a></h4>
        <div id="col1content" class="collapse">Text lorem ipsum.</div>
      </div>
    </div>
  </div>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>

</html>

Answer №1

The Bootstrap JS library being imported is version v3, while the CSS version is v4. It's essential for both the CSS and JS to be the same version.

To resolve this, import the v4 JS library instead.

.jumbotron {
  background-color: #2E2D88;
  color: white;
}


/* Adds borders for tabs */

.tab-content {
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 10px;
}

.nav-tabs {
  margin-bottom: 0;
}
<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 Tutorial</title>
  <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 1</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 2</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 3</h4>
        <p>Lorem ipsum</p>
      </div>
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4>Column 4</h4>
        <p>Lorem ipsum</p>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-1 col-md-3 col-sm-6 col-xs-12">
        <h4><a href="#col1content" data-toggle="collapse">Column 1</a></h4>
        <div id="col1content" class="collapse">Text lorem ipsum.</div>
      </div>
    </div>
  </div>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

</body>

</html>

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

Tips for properly formatting the data before sending it to an API

When a user submits a form, the data is sent to an API. It's important that every field appears on a new row in the output. Unfortunately, using \n and <br> inside the string does not produce the desired formatting. Can you help me with thi ...

Bootstrap's anchored footer fix

Exploring Bootstrap and I'm curious about how to keep the footer fixed at the bottom of the page without it disappearing when scrolling through the content. Any suggestions? ...

Customize the appearance of the placeholder text in ui-select-match

I am trying to style the placeholder text of the following element: <ui-select-match placeholder="My hint"> {{$someItem}} </ui-select-match> I want to change the style of the placeholder text to be bold, italic, or other formatting option ...

What steps should I take to ensure that the getElementsbyName function works properly on both Internet Explorer and Firefox browsers

Encountering a JavaScript error in IE but not in FF ("document.getelementsbyname(...).0.innerhtml is null or not an object": var oldVal = parseInt(document.getElementsByName("outSL")[0].innerHTML); //value pulled from the database Here is the asp.net c ...

Swap out the traditional submit button on your form with a stylish Font Awesome

Can anyone assist with replacing the submit button with a Font Awesome icon? I've tried it myself, but the icon is not displaying on the button. Here is what I have attempted so far: <form action="{{route('destroycourse', $course->id) ...

When utilizing direction:rtl in Chrome, a vertical scrollbar is displayed on the right side of the page

Whenever I include style='direction: rtl;', the vertical scrollbar is supposed to move to the left side instead of the right. While this behavior is observed in Internet Explorer and Firefox, Chrome seems to keep the scrollbar on the right. Is t ...

How to style date strings in JavaScript, jQuery, or CSS

Below are dates that need formatting: 7-sep, 14-sep, 21-sep, 28-sep, 5-oct,12-oct, 19-oct,26-oct, 2-nov, 9-nov, 16-nov, 23-nov,30-nov, 7-dec,14-dec, 21-dec,28-dec-2013. Is there a way to tidy them up using JavaScript, jQuery, or CSS? Ideally, I would lik ...

The Yahoo stock display is experiencing issues within two separate div elements on the webpage

Hey experts on stack overflow! I came across this script that allows me to fetch stock information from Yahoo. However, I'm facing an issue where the script only works for one div when I try to use it in multiple divs. I'm not a coder, so I&apos ...

What steps can be taken to ensure the Instagram logo remains visible even when it is being hovered over?

Struggling to incorporate a social media icon on my website, I am facing an issue where the Instagram icon outline disappears on hover due to the gradient styling in CSS3. Below is my current code: .social-icons li.instagram a { border-radius: 50%; ...

Avoiding Incorrect Form Beginnings - The Essentials of Bootstrap Forms

Is there a way to customize the default validation of bootstrap so that the form is only marked as invalid after a certain action? <form [formGroup]="simuladorForm" class="was-validated"> <div class="row"> <div class="col-md-1 ...

Apply the transition property to all elements except for the text inside a specific tag

I'm wondering if it's possible to apply a hover transition effect to everything in this tag except the text within it. The desired effect is for the button to fade away while the text remains visible. Below is the code I have written so far: ul ...

Unexpected behavior in Bootstrap 4 table column sizing issue detected

Recently delving into the realm of bootstrap and HTML/CSS scripting, I've been working on creating a simple HTML table with one row and three columns. Each column is supposed to evenly take up one third of the table's space. However, I'm fac ...

Implementing text wrapping within input elements for optimal print.css layout

Can you help me with a print.css issue I'm experiencing? I am currently working on my print stylesheet and I've encountered a challenge where I need to word wrap input fields to ensure all the text is displayed correctly. Despite trying various ...

5-item carousel in CSS gridView

I'm currently working on a thumbnail slider project. My goal is to display 5 thumbnails at a time, and allow users to move to the next or previous set of thumbnails by clicking on the corresponding buttons. I attempted to modify an existing slider tha ...

Ways to add a header to the second cell in an HTML table and methods for positioning a table next to another table

I've been working on something similar and I'm trying to add a heading to the second cell of a table. Does anyone know how to accomplish this? <tr> <td><label for="prodnumber">Search string for product number</td> & ...

What steps can be taken to avoid the table row from getting hidden behind the table header?

I am aiming to implement sticky headers for a table using only CSS. You can refer to this link for guidance: Table fixed header and scrollable body Everything looks good when the page loads, but as soon as I start scrolling, a sliver of data appears abo ...

ng-repeat failing to display the final two divs

I'm having trouble with the following code. The second to last div inside the ng-repeat is not being rendered at all, and the last div is getting thrown out of the ng-repeat. I can't figure out what's wrong with this code. Can anyone spot th ...

The main-panel div's width increase is causing the pages to extend beyond the window's width limit

I recently downloaded a Reactbootstrap theme and managed to integrate it with NextJS successfully. However, I am facing an issue where my <div className="main-panel"> in the Layout.js is extending slightly beyond the window. It seems like t ...

Can someone guide me on the process of assigning multiple classes in my situation?

Can someone assist me with combining multiple classes in an ng-class statement? I am attempting to utilize multiple classes for my element using ng-class. Here is what I have: <div id='test' ng-class="{blue: test, scale: scale, 'non-sca ...

Tips for avoiding HTML injections in HTML tooltips

I'm attempting to create a tooltip using HTML, but I need to escape specific HTML elements within it. So far, my attempts have been unsuccessful. Take a look at the example I've provided: http://jsfiddle.net/wrsantos/q3o1e4ut/1/ In this example ...