The collapsed button on the Bootstrap 4 accordion flickers slightly as it expands, not reaching its full expansion

I'm currently working on implementing an accordion feature. I found inspiration from this component here on fiddle which utilizes bootstrap 4. While attempting to troubleshoot a bug in the SO forum, I noticed that on my page, the component seems to "blink" momentarily just before fully expanding. The page is hosted on Moodle and unfortunately, as an admin with frontend editing access only, I can't delve into server-side configurations. My suspicion is that there might be conflicts within the existing stylesheets of this specific page. Any insights or help regarding my code would be greatly appreciated.

.spacer {
   height: 1em;
}
#competence {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

#competence td, #competence th {
    border: 1px solid #ddd;
    padding: 8px;
}

#competence tr:nth-child(even){background-color: #f2f2f2;}

#competence tr:hover {background-color: #ddd;}

#competence th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: #4CAF50;
    color: white;
}
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<div id="accordion">
    <div class="card">
        <div class="card-header" id="headingOne">
            <h5 class="mb-0">
        <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<b>
A table
</b>
        </button>
        </h5>
        </div>
        <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
            <div class="card-body">
<div dir="ltr">
    <table id="competence">
        <colgroup>
            <col width="332">
            <col width="129">
            <col width="125">
        </colgroup>
        <tbody style="border-color:black;">
            <tr>
                <td>
                    <p dir="ltr">Some text</p>
                </td>
                <td colspan="2" rowspan="3">
                    <p dir="ltr">Some text</p>
                </td>
            </tr>
            <tr>
                <td>
                    <p dir="ltr">Some text</p>
                </td>
            </tr>
            <tr>
                <td>
                    <p dir="ltr">Some text</p>
                </td>
            </tr>
            <tr>
                <td>
                    <p dir="ltr">Some text</p>
                </td>
                <td>
                    <p dir="ltr">Some text</p>
           [...]
t;
                </td>
            </tr>
            <tr>
                <td>
                    <p dir="ltr">Some text</p>
                </td>
                <td colspan="2">
                    <p dir="ltr">Some text</p>
                </td>
            </tr>
        </tbody>
    </table>
</div>

            </div>
        </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>

Any ideas on what could be causing this behavior?

Answer №1

Encountered a similar issue with collapsible items, which was caused in my situation by adding padding to the "collapsible" div like so

<div class="collapse pb-3" id="collapseExample">
I was able to fix it by removing the "pb-3" class from there and instead adding the pt-3 class to the non-collapsible div element below.

Answer №2

To create a collapsible div, ensure it has the class "card" and no padding.

<html>

<head>
  <link rel="stylesheet"       
        href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="75171a1a01060107140535415b435b45">[email protected]</a>/dist/css/bootstrap.min.css">

  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9af8f5f5eee9eee8fbeadaaeb4acb4aa">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
</head>

<body>
  <div class="p-5">
    <button class="btn btn-primary clickable d-block" aria-controls="accordion" 
            data-toggle="collapse" data-target="#accordion">Click me!</button>
    <div class="card m-0 collapse" id="accordion" 
         style="background-color:#d7dde3;border-radius:0">
      <p class="pl-2">Line 1</p>
      <p class="pl-2">Line 2</p>
      <p class="pl-2">Line 3</p>
    </div>
  </div>
</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

Utilizing HTML/CSS with React/Bootstrap: A Comprehensive Guide

Looking for help with integrating HTML/CSS code into React/Bootstrap? I need assistance with coding in React using Bootstrap. How do I effectively use components and props? Even after installing bootstrap, I am encountering errors. Is it possible to dire ...

Simple HTML generator using Node.js

My preference is to write my HTML in a basic and straightforward manner, without any fancy tools. The only feature I would like to have is the ability to use an include statement to easily add header, navigation, and footer sections to each page. I'v ...

Transfer the photo and save it to my database

I've been working on creating a form to upload images and store them in my database, but I'm facing some challenges: Notice: Undefined index: fileToUpload in C:\xampp\htdocs\confee\admin\upload.php on line 3 Notice: Un ...

Exploring the different ways to compare data with the load() method

I am faced with a coding dilemma. I have two pages: data.php and index.html. The data.php page contains a single value (let's say 99), while the index.html page uses jQuery to dynamically load the data from data.php into a div called "data" every 2 se ...

Connecting a button's action to a specific element in an array using AJAX and Firebase

I am currently working on a project that involves making an AJAX request from a social API and then appending the results with a button inside the div. This button is meant to save the corresponding item in the array to my Firebase database. For brevity, ...

What is the reason for hasChildNodes returning true when dealing with an Empty Node?

When the user clicks on purchase and the cart is empty, there should be an alert. However, it seems that no response is triggered. Upon running the program, an error message appears stating that it cannot read the property of addEventListener which is unde ...

How can you add a new div directly after the parent div's content and display it in-line?

I have a banner that stretches to fill the width completely. Inside this main div, there is another smaller div measuring 30px in size positioned at the end. The nested div contains a close icon background image, and upon clicking it, the entire banner get ...

Having trouble with importing and receiving the error message "Module 'clone' not found."

When trying to use clone.js in Angular 2, I imported it with import * as clone from 'clone'. It was listed in my package.json dependencies and successfully imported into node_modules. However, when viewing the output, I encountered the error mes ...

Dynamic navigation menu shifting when bolded

Looking at my menu, you'll notice the following layout: If one clicks on Recruitment in the menu, it correctly bolds the text as intended. However, an issue arises where the entire menu unexpectedly shifts 1 or 2px to the left. The menu is implemente ...

Using Javascript to dynamically add SVGs from an array

Having issues with displaying SVG images in a quiz I'm building. I have a folder full of SVGs that correspond to each multiple choice option, but I can't seem to get the pathway right for them to show up properly. I've tried using template l ...

"Implementing a Callback Function when Jquery Countdown Reaches

Implementing this plugin will result in a live countdown displayed on the webpage. I recently reviewed the on.finish callback documentation found on the Official website. The main objective is to hide the span#limit once the timer completes its countdown ...

The jQuery function does not accurately represent the class change made by another event

When hovering over a class anchor, an alert will display the title value. If the anchor has a nohover class, a nopop class will be added to prevent the alert. This ensures that the alert only appears when hovering over the class anchor without the nopop cl ...

Tips for executing a function whenever unfamiliar anchor elements are selected in Vue.js 3

I am utilizing a div with v-html to showcase data fetched from a database: <div id="Content" v-html="${Content}"></div> Inside the presented ${Content}, there may be various a tags linking to external pages. I aim to parse ...

What might be the reason for jQuery not functioning in Internet Explorer 11?

Working on developing a slideout menu for my website using jQuery. It functions perfectly in Chrome, but encountering issues in Internet Explorer (IE11). Extensive search hasn't provided a solution yet. Seeking assistance and any help would be highly ...

The Node.js application appears to be unresponsive on the designated port

When specifying port 30000, my app ends up listening on a different port unexpectedly. Below is the code snippet I have written: var express = require('express'); var bodyParser = require('body-parser'); var path = require('path& ...

Choose a specific field from a Django filter option

Just had a quick query: Is there a way for me to choose only one field from my filter form in Django? At the moment, I'm showcasing the entire form: <div class="container"> <form method="GET" > {{ filter.form.Precio|crispy }} ...

The criteria set by jQuery are met

I have developed my own custom form validation for two inputs: one for a phone number and the other for an email address. Additionally, I have integrated two forms on a single page. Here is a snippet of my code: var email, phone; if (email address passe ...

Develop a search feature that automatically filters out special characters when searching through a

I am currently developing a Vue-Vuetify application with a PHP backend. I have a list of contacts that include first names, last names, and other details that are not relevant at the moment. My main query is how to search through this list while disregardi ...

What could be the reason my function is not showing any data?

Using AngularJS in web development $scope.fetchData = function(dateTime) { console.log(dateTime + " fetch"); $http({ method: 'GET', url: 'https://api.example.com/appointments', params: { date ...

Setting up ESLint for TypeScript with JSX configuration

I am encountering problems with TypeScript configuration. Below is the code snippet from my tsconfig.json: { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLib ...