Can someone assist me in collapsing one element while expanding another in Bootstrap 4?

Incorporating four div cards functioning as buttons to collapse and expand information beneath the card row has resulted in unexpected behavior. Clicking on one card should expand its information while collapsing the previously expanded card, but the implementation seems to be stacking the information instead of collapsing the first card and expanding the second. Despite researching and finding a related question with a provided answer, the implemented solution does not resolve the issue. Can anyone assist in identifying the problem? Reference the answered question here.

Below is the answer from the referenced post, integrated into the code but not functioning properly.

Review the screen capture of the answer for additional context.

Attempts to implement other solutions have also been unsuccessful. The code in question is as follows:

p, h1 {
 font-family: 'Droid Sans', sans-serif;
}

...

Answer №1

Make sure that the data-parent="#myGroup" attribute is placed within a div element that has the collapse class.

p, h1 {
 font-family: 'Droid Sans', sans-serif;
}

.containerS {
margin-right: 2%;
margin-left: 2%;
}

.card:hover {
    -webkit-box-shadow: -1px 9px 40px -12px rgba(0,0,0,0.75);
    -moz-box-shadow: -1px 9px 40px -12px rgba(0,0,0,0.75);
    box-shadow: -1px 9px 40px -12px rgba(0, 0, 0, 0.75);
    transform: scale(1.02)

}
.card {
  
border-radius: 3px;
    border: 1px solid #bb9c4c;
    overflow: hidden;
    padding-bottom:10px;
    margin: 20px 0px 0px 0px;
    align: center;
    transition: transform .1s;
    color: black;
}
.card img {
transition: transform .1s
}

.card img:hover {
  -moz-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  transform: scale(1.01);
}



.btn {
background-color: #bb9c4c;
border-color: #bb9c4c;
}
.card-body {
padding: 10px;
}


.services {
background-color:#242424;
 color:white;
padding:90px 0 90px;
text-align:center;
overflow: hidden;
}



.services h1 {
font-size:2em;
padding-bottom: 30px;
}

.services h3 { 
font-weight:normal;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
     [...]
    <title>Hello, world!</title>
  </head>
  <body>


<div class="services" id="services">
      <div class="containerS">
        <div class="row">
          <div class="col-lg-12 col-md-12">
            <h1>Meow</h1>
          </div>
        </div>
          <div id="myGroup">
          <div class="row">
            <div id="mentor" class="colo-lg-3 col-md-3 col-sm-3 col-xs-6 wow flipInY" data-wow-delay="0.2s">
              <div class="card" style="width:100%;" data-toggle="collapse" data-target="#collapseExample1" role="button" aria-expanded="false" aria-controls="collapseExample1">
               [...]
            [...]
        </div>
             [...]
    </div>
    
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
     [...]
  </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

Accessing feedback from Reddit's API

After writing some code to search Reddit's API with a specific query, I now want it to display comments as well. Inside my $.getJSON statement that retrieves each title/post based on the search query, I have the following nested code block. The goal i ...

Substitute the string (3-11-2012) with a different date layout (3 november 2012)

Can anyone guide me on how to convert text strings like '11-1-2012' into date strings like '11 januari 2012'? I've been looking for a solution, but haven't found exactly what I need. The month names should be in Dutch. I attem ...

Submit JSON data that is not empty in the form of a custom format within the query string

Attempting to transmit JSON data using a GET request. JSON data: var data = { country: { name: "name", code: 1 }, department: {}, cars: ["bmw", "ferrari"], books: [] } Code for sending: var posting = $.ajax({ ur ...

"Implementing responsive design with Bootstrap's carousel through media queries

I'm having some trouble creating a basic carousel using bootstrap because the images are not displaying full screen. Do I need to use media queries to achieve this and if so, how can I implement them? <div id="myCarousel" class="carousel slide" da ...

Unable to change the color of InputBase component's placeholder in React.js

I've been attempting to modify the color of the placeholder in an inputbase. I came across several methods online and tried implementing them, but none have been successful. Below are the codes I have tried. <InputBase id="input-id&quo ...

Tips for adjusting image size in Bootstrap carousel

Is it possible to change the width of the image in this carousel? How can I resize the image without affecting the red box? I've tried numerous solutions on various forums, but none seem to work. The image just won't shrink the way I want it to ...

Sorting a list with anchor tags alphabetically using Javascript/JQuery

Here is a list of services: <ul id="demoOne" class="demo"> <li><a href='http://site/Service.aspx?shId=1154'>Copy service for files from folder 12</a></li> <li><a href='http://site/Service.aspx? ...

Navigate to the middle of the visible area

Is there a way to automatically center a div when it is clicked, so that it scrolls to the middle of the browser viewport? I have seen examples using anchor points but I want to find a different solution. Any ideas on how to accomplish this without using ...

Tips on integrating Codrops tutorial codes into a SilverStripe website project

Exploring the vast array of tutorials and code examples on the Codrops site has been an enlightening experience. Codrops Website I'm eager to incorporate some of these resources into my SilverStripe projects as well. SilverStripe CMS After learning h ...

Retrieving text content from multiple classes with a single click event

There are numerous elements each having class names p1, p2, p3,...p14. Consequently, when attempting to extract text from the clicked class, text from all classes is retrieved! For instance, if the expected text is 80, it ends up being 808080080808080808 ...

Decompressing CSS in PhpStorm

I'm currently using PhpStorm version 2016.3.2. Occasionally, I come across <style> tags in my HTML files containing minified CSS code. Is there a way to create a shortcut for unminifying the code within these tags? For instance, the following ...

Creating a table with React components to display an object

I'm a React novice struggling to render an object in a table. While I can access the ctx object using console.log, I can't seem to display it in the table on the browser. Any help and advice would be greatly appreciated. The code snippet is provi ...

Determine if the JQuery change event is not triggered by a hyperlink

I have integrated the Nestable script from this source and I'm looking for a way to include clickable links in the navigation items that can be moved around. Currently, adding a link to the <li> element causes the entire navigation to behave un ...

Transferring information from offspring to parent

Greetings! I'm currently getting my feet wet with React and finding myself stuck on an issue regarding passing states. Is it possible for me to pass a child state to a parent component in order to selectively render other child components? ...

Error alert: $.simpleWeather function not found

Currently, I am attempting to incorporate simpleWeather.js from the website simpleweatherjs.com into my own website. However, upon inserting the html code onto my website, an error message pops up: Uncaught TypeError: $.simpleWeather is not a function ...

Having trouble with the Tooltip feature in Bootstrap versions 5.2 and 5.3 on my end

I've been working on building an HTML website using Bootstrap 5.2, and I followed the instructions in the Bootstrap documentation to add tooltips. However, I encountered an issue where the tooltips were not functioning as expected. When checking the ...

I am experiencing issues with staying logged in while using Passport and sessions. The function "isAuthenticated()" from Passport continuously returns false, causing me to not remain logged in

I have been working on implementing authentication with Angular, Passport, and sessions. I can successfully create a new user and log in, but I am facing an issue: Problem Every time I check if the user is authenticated using Passport's isAuthentica ...

Every time Lodash.uniqueId is called, it consistently generates the value of

Consider using the lodash library, specifically version 4.17.11. _.uniqueId() seems to consistently output 1 instead of a random three-digit number. Similarly, _.uniqueId('prefix') always returns prefix1. Do you see this as a potential issue? ...

Create a Grid-Item-List with a custom arrangement, utilizing techniques like flex-box to achieve the desired layout

Struggling to create a unique grid-list that looks great on both desktop and mobile devices. Any tips or solutions would be greatly appreciated! I need a list (left image) with a special layout, which can be achieved through nested grids. However, I want ...

Identifying instances where the AJAX success function exceeds a 5-second duration and automatically redirecting

Greetings! I have created a script that allows for seamless page transitions using Ajax without reloading the page. While the script functions perfectly, I am seeking to implement a feature that redirects to the requested page if the Ajax request takes lo ...