Add a Collapsing Footer in a Card (Bootstrap) - html

I made three blocks – using the CARD class in bootstrap. That worked well. Now I'd like to add a footer (or just a div) to the card that allows to "Show/Hide Details".
I tried 10 different ways and the cards always "break" for some reason. I have the code that works for the cards but without the collapsing
The goal is to have the last 3 lines collapsing, while the "Show payment schedule" changes to "Hide payment schedule".
Who knows how to get there? Where to put the div class for the collapsing without breaking the card?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<!-- Wrapper for Cards -->
<div class="row mx-n2">
<div class="col-sm-6 col-md-4 px-2 mb-3 mb-md-0">
<!-- Card 1 -->
<a class="card h-100 transition-3d-hover" href="#">
<img class="card-img-top" src="../../assets/img/480x220/monthly.gif" alt="Monthly Animation">
<div class="card-body">
<h4>Monthly</h4>
<p class="font-size-1 text-body mb-0">You will be charged every month the amount of</p>
<h3 class="text-center font-weight-bold text-black-50 mb-0 mt-4">USD 43</h3>
</div>
<hr/>
<!-- Collapsing Footer -->
<div class="card-footer border-0 pt-0">
<span class="font-size-1 text-black-50">Show payment schedule</span>
<div class="row pt-2">
<div class="col">
<span class="today font-size-1 text-black-50" data-toggle="tooltip" data-html="true" id="today">Today</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 43</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">June 2020</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 43</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">July 2020</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 43</span>
</div>
</div>
</div>
<!-- End Collapsing Footer -->
</a>
<!-- End Card 1 -->
</div>
<div class="col-sm-6 col-md-4 px-2 mb-3 mb-md-0">
<!-- Card 2 -->
<a class="card h-100 transition-3d-hover" href="#">
<img class="card-img-top" src="../../assets/img/480x220/quarterly.gif" alt="Quarterly Animation">
<div class="card-body">
<h4>Quarterly</h4>
<p class="font-size-1 text-body mb-0">You will be charged every third month the amount of</p>
<h3 class="text-center font-weight-bold text-black-50 mb-0 mt-4">USD 102</h3>
</div>
<hr/>
<!-- Collapsing Footer -->
<div class="card-footer border-0 pt-0">
<span class="font-size-1 text-black-50 ">Show payment schedule</span>
<div class="row pt-2">
<div class="col">
<span class="today font-size-1 text-black-50" data-toggle="tooltip" data-html="true" id="today">Today</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 102</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">July 2020</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">July 2020</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">July 2020</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 43</span>
</div>
</div>
</div>
<!-- End Collapsing Footer -->
</a>
<!-- End Card 2 -->
</div>
<div class="col-sm-6 col-md-4 px-2 mb-3 mb-md-0">
<!-- End Card 3 -->
<a class="card h-100 transition-3d-hover" href="#">
<img class="card-img-top" src="../../assets/img/480x220/yearly.gif" alt="Yearly Animation">
<div class="card-body">
<h4>Annually</h4>
<p class="font-size-1 text-body mb-0">You will be charged once every year the amount of</p>
<h3 class="text-center font-weight-bold text-black-50 mb-0 mt-4">USD 408</h3>
</div>
<hr/>
<!-- Collapsing Footer -->
<div class="card-footer border-0 pt-0">
<span class="font-size-1 text-black-50">Show payment schedule</span>
<div class="row pt-2">
<div class="col">
<span class="today font-size-1 text-black-50" data-toggle="tooltip" data-html="true" id="today">Today</span> </div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">April 2021</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">April 2022</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
</div>
<!-- End Collapsing Footer -->
</a>
<!-- End Card 3 -->
</div>
</div>
<!-- End Wrapper for Cards -->

Like this? for more info, visit https://getbootstrap.com/docs/4.4/components/collapse/
Explanation
I added
data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample"
to your span so, it works like collapsable toggler and added root div with
class="collapse show" id="collapseExample"
to your three items so only one div can collapse.
document.querySelectorAll('.change_text').forEach(cur => {
cur.addEventListener('click', e => {
const target = e.target;
if (target.textContent === 'Show payment schedule') {
target.textContent = 'Hide payment schedule';
} else {
target.textContent = 'Show payment schedule';
}
})
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="row mx-n2">
<div class="col-sm-6 col-md-4 px-2 mb-3 mb-md-0">
<!-- End Card 3 -->
<div class="card h-100 transition-3d-hover" href="#">
<img class="card-img-top" src="../../assets/img/480x220/yearly.gif" alt="Yearly Animation">
<div class="card-body">
<h4>Annually</h4>
<p class="change_text font-size-1 text-body mb-0">You will be charged once every year the amount of</p>
<h3 class="text-center font-weight-bold text-black-50 mb-0 mt-4">USD 408</h3>
</div>
<hr/>
<!-- Collapsing Footer -->
<div class="card-footer border-0 pt-0">
<a class="change_text font-size-1 text-black-50" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">Show payment schedule</a>
<div class="collapse show" id="collapseExample">
<div class="row pt-2">
<div class="col">
<span class="today font-size-1 text-black-50" data-toggle="tooltip" data-html="true" id="today">Today</span> </div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">April 2021</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
<div class="row">
<div class="col">
<span class="font-size-1 text-black-50" data-toggle="tooltip" data-html="true" title="placeholder">April 2022</span>
</div>
<div class="col">
<span class="font-size-1 text-black-50">USD 408</span>
</div>
</div>
</div>
</div>
<!-- End Collapsing Footer -->
</div>
<!-- End Card 3 -->
</div>
</div>

It looks like your collapsing section is just another card element nested in the parent card element. According to the docs, Bootstrap has a Collapse element and it's used in conjunction with data-toggle="collapse" when the element triggering the animation is a link. When the element triggering the animation is a div, like in your case, you have to give it the class collapse.
The docs show an examples for both. Trying something like the second part:
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
Link with href
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
Button with data-target
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>

Related

How to make bootstrap columns automatically resize when element overflows them

I have a BootStrap 5 row, the columns of which will always remain the same, even if the content inside of them overflows the column. How do I make it so that when content is larger than the column, the column expands in size?
As you can see, the columns (purple) let the cards inside of them overflow, therefore causing them to collide with other cards. What I want is for the columns to expand when the content inside of them is bound to overflow.
HTML for rows and columns:
<div class="row">
<div class="col">
<h1 class="header">User</h1>
<div class="card card-large border-0 me-1">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-user-pen" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Username: </a>
<a class="header row pt-2">Plan: </a>
<a class="header row pt-2">Discord: </a>
<a class="header row pt-2">Date of registration: </a>
<a class="header row pt-2">Used searches: /</a>
</div>
</div>
<div class="mt-2">
<a class="btn shadow text-white me-1" style="background-color: #7289da">Link Discord</a>
<a class="btn btn-secondary shadow text-white me-1">Change password</a>
<a class="btn btn-danger shadow text-white" data-bs-toggle="modal" data-bs-target="#logout">Log out</a>
<div class="modal fade" id="logout" data-bs-backdrop="logout" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" style=" width: 25rem">
<div class="modal-content text-white">
<div class="modal-body" style="background-color: #0e0e0e">
<div class="container">
<div class="row justify-content-center">
<div class="col-1" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-triangle-exclamation" style="font-size: 50px;"></i>
</div>
<div class="col-8 mt-4">
Are you sure you wish to log out?
</div>
</div>
</div>
</div>
<div class="modal-footer border-0 justify-content-center" style="background-color: #0e0e0e">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button data-bs-dismiss="modal" type="button" class="btn btn-danger" #click="deleteCookie()">Log out</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col">
<h1 class="header">Plan</h1>
<div class="card card-large border-0 me-1">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-tag" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Plan: </a>
<a class="header row pt-2">Date of Purchase: </a>
<a class="header row pt-2">Date of Expiration: </a>
</div>
</div>
<div class="mt-2">
<a class="btn btn-primary shadow text-white me-1" #click="">Upgrade</a>
<a class="btn btn-danger shadow text-white">Cancel</a>
</div>
</div>
</div>
</div>
<div class="col">
<h1 class="header">API</h1>
<div class="card card-large border-0 me-3">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-code" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Used searches: /</a>
</div>
</div>
<div class="mt-2">
<a class="btn btn-secondary shadow text-white me-1 disabled">API docs</a>
<a class="btn btn-secondary shadow text-white me-1" onclick="">Copy API key</a>
<a class="btn btn-secondary shadow text-white">Regenerate API key</a>
</div>
</div>
</div>
</div>
</div>
Add col-lg-4 in column row like this
<div class="row">
<div class="col-lg-4">
//content
</div>
<div class="col-lg-4">
//content
</div>
<div class="col-lg-4">
//content
</div>
</div>
For more information, please visit this link : https://getbootstrap.com/docs/5.2/layout/columns/#how-they-work

One Bootstrap carousel wrongly mixing photos with another bootstrap carousel from the same page

I added 2 bootstrap 5 carousels on the same page, added unique ID to each of them, but sadly the second carousel mixes photos with the first carousel. It takes 2 photos from the previous slide. Adding unique ID's to each carousel didn't change the situation.
Is there a solution to this?
I checked also this post but it didn't help:
How to place two bootstrap carousels in the same page?
<!-- Bootstrap carousel 1 -->
<div class="container text-center my-3 mb-5">
<div class="row mx-auto my-auto justify-content-between">
<div id="Carousel-1" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person1.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>John Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Administration</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person2.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Sarah Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Finance</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person3.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Roger Kensinghton</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Security</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person4.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Kelly Parker</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Design</p>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev bg-transparent w-aut" href="#Carousel-1" role="button" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next bg-transparent w-aut" href="#Carousel-1" role="button" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
</div>
</div>
<!-- Bootstrap carousel 2 -->
<div class="container text-center my-3 mb-5 carousel2">
<div class="row mx-auto my-auto justify-content-between">
<div id="Carousel-2" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/woman1.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Jane Dow</strong>
<p class="mt-0 me-2" style="font-size: 13px;">CEO AXA Group</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/man1.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Dave Johnson</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Marketing Manager Johnson's & Co</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/man2.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Roger Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">CEO Hi-Tech Intl.</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/woman2.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Diana Russel</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Manager Creativity Hub</p>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev bg-transparent w-aut" href="#Carousel-2" role="button" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next bg-transparent w-aut" href="#Carousel-2" role="button" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
</div>
</div>
let items = document.querySelectorAll('.carousel .carousel-item')
items.forEach((el) => {
const minPerSlide = 3
let next = el.nextElementSibling
for (var i=1; i<minPerSlide; i++) {
if (!next) {
// wrap carousel by using first child
next = items[0]
}
let cloneChild = next.cloneNode(true)
el.appendChild(cloneChild.children[0])
next = next.nextElementSibling
}
})
because you use .carousal selector and class is present in both carousals use ids instead of class #Carousel-1 or #Carousel-2
let items = document.querySelectorAll('#Carousel-1 .carousel-item')

angular bootstrap div width not showing full only on ipad

I have 2 columns in a single Row. Its working fine but on IPAD its not showing full width.
MY CODE
<div class="row">
<div class="col-xl-8 col-lg-8 col-sm-12">
<div class="card mb-4">
<div class="card-header">
<div class="card-title-wrap bar-info">
<div class="card-title">Personal Information</div>
</div>
</div>
<div class="card-body">
<div class="card-block">
<div class="align-self-center halfway-fab text-center">
<a class="profile-image">
<img src="assets/img/portrait/medium/avatar-m-9.jpg"
class="rounded-circle img-border gradient-summer width-100" alt="Card image">
</a>
</div>
<div class="text-center">
<span class="font-medium-2 text-uppercase">{{selectedPatient?.patientName}}</span>
<p class="grey font-small-2"></p>
</div>
<div class="row align-self-center">
<div class="col-12 col-sm-6">
<ul class="no-list-style pl-0 text-center">
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
ID: </a></span>
</div>
<div class="d-inline-block">
<span class="">
<span class="display-block overflow-hidden">
{{selectedPatient?.mrn}}</span>
</span>
</div>
</div>
</li>
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Case #:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span class="display-block overflow-hidden"> Ninja Developer</span>
</span>
</div>
</div>
</li>
</ul>
</div>
<div class="col-12 col-sm-6">
<ul class="no-list-style pl-0 text-center">
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Age:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span
class="display-block overflow-hidden"> {{selectedPatient?.age}}</span>
</span>
</div>
</div>
</li>
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Contact Number:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span
class="display-block overflow-hidden"> {{selectedPatient?.phone}}</span>
</span>
</div>
</div>
</li>
</ul>
</div>
<div class="col-12 col-sm-6">
<ul class="no-list-style pl-0 text-center">
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Address:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span
class="display-block overflow-hidden"> {{selectedPatient?.address}}</span>
</span>
</div>
</div>
</li>
</ul>
</div>
<div class="col-12 col-sm-6">
<ul class="no-list-style pl-0 text-center">
<li class="mb-2">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Email:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span
class="display-block overflow-hidden"> {{selectedPatient?.email}}</span>
</span>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-lg-12 col-sm-12">
<!--About div starts-->
<div id="about">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<div class="card-title-wrap bar-info">
<div class="card-title">Shedule Appoinment</div>
</div>
</div>
<div class="card-body">
<div class="card-block">
<div class="mb-3">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
DR Micky:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span> 7 Feb</span>
</span>
</div>
</div>
<span class="display-block overflow-hidden">Lorem Ipsum is simply dummy text of the
printing and typesetting industry.
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="about">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<div class="card-title-wrap bar-info">
<div class="card-title">Medication</div>
</div>
</div>
<div class="card-body">
<div class="card-block">
<div class="mb-3">
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Lisinoril 1 in tab:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span> Feb 1, 2020</span>
</span>
</div>
</div>
<div class="d-flex align-items-center">
<div class="d-inline-block">
<span class="text-bold-500 primary"><a><i class="ft-briefcase font-small-3"></i>
Lisinoril 1 in tab:</a></span>
</div>
<div class="d-inline-block">
<span class="">
<span> Feb 1, 2020</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Its showing full width on all devices but on IPAD only its leaving some white space so my text is coming out I need to show full width in this so it can cover whole area in white.
I try to give it like this col-xl-8 col-lg-8 col-sm-12 but its also not working.
Just change second line with below and it will work!
<div class="col-xl-8 col-lg-12 col-sm-12">

A button which contain a description will be hidden inside mobile view

I am working on an asp.net core MVC >> inside y view i am showing a FAQ section. as follow:-
<div class="container">
<div class="row ">
<div class="col-xl-2 mx-auto d-none d-sm-block">
<div class="service_details_left">
<div class="nav nav-pills" id="v-pills-tab" role="tablist"
aria-orientation="vertical">
</div>
</div>
</div>
<div class="accordion_area col-xl-8">
<div class="faq_ask">
<h3 class="large-heading-3">Frequently Asked Questions</h3>
<div id="accordion">
#foreach (var item2 in Model.OrderBy(a => a.Order))
{
<div class="card">
<div class="card-header" id="#item2.Id+'headingTwoa'">
<h5 class="mb-0">
<button class="btn btn-link collapsed " data-toggle="collapse"
data-target="##item2.Id" aria-expanded="false"
aria-controls="collapseTwo">
<span class="expandable-heading"> #Html.DisplayFor(modelItem => item2.Description)</span>
</button>
</h5>
</div>
<div id="#item2.Id" class="collapse" aria-labelledby="headingTwoa"
data-parent="#accordion" style="">
<div class="card-body">
#Html.Raw(item2.Answer)
</div>
</div>
</div>
}
</div>
</div>
</div>
<div class="col-xl-2">
</div>
</div>
</div>
but on wide screen the FAQ will be shown correctly, as follow:-
while on mobile view the question's description will be hidden as follow!!
any advice on this please?
You can try this snippet.
<div class="container">
<div class="row ">
<div class="col-xl-2 mx-auto d-none d-sm-block">
<div class="service_details_left">
<div class="nav nav-pills" id="v-pills-tab" role="tablist"
aria-orientation="vertical">
</div>
</div>
</div>
<div class="accordion_area col-xl-8">
<div class="faq_ask">
<h3 class="large-heading-3">Frequently Asked Questions</h3>
<div id="accordion">
<div class="accordion" id="accordion">
#foreach (var item2 in Model.OrderBy(a => a.Order))
{
<!-- here -->
<div class="card">
<div class="card-header" id="headingTwoa_#item2.Id">
<h5 class="mb-0">
<button class="btn btn-link collapsed " data-toggle="collapse"
data-target="#collapse_#item2.Id" aria-expanded="true"
aria-controls="#item2.Id">
<span class="expandable-heading"> #Html.DisplayFor(modelItem => item2.Description)</span>
</button>
</h5>
</div>
<div id="collapse_#item2.Id" class="collapse" aria-labelledby="headingTwoa_#item2.Id"
data-parent="#accordion" >
<div class="card-body">
#Html.Raw(item2.Answer)
</div>
</div>
</div>
}
</div>
</div>
</div>
</div>
<div class="col-xl-2">
</div>
</div>
</div>
Note: id needs to start with a letter.

Putting a button inside a collapsing card in Bootstrap

I am trying to put a button in a collapse (part of an accordion) that will go to a new page when clicked. But right now when I try to click the button, it instead just closes the collapse.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div id="accordion">
<div class="card">
<div class="card-header p-1">
<a class="card-link stretched-link text-body" data-toggle="collapse" href="#collapseOne">
<div class="row no-gutters">
<div class="col-8 pl-1"><strong>Title </strong></div>
<div class="col-4 text-right"><span class="badge badge-danger p-1">High Priority</span></div>
</div>
<div class="row no-gutters">
<div class="col text-center">
<!-- Lock this to prevent word wrap from too mane names -->
<span class="badge badge-pill badge-primary mr-1">Name</span><span class="badge badge-pill badge-primary mr-1">Name</span><span class="badge badge-pill badge-warning mr-1">Name</span>
</div>
</div>
</a>
</div>
<div id="collapseOne" class="collapse" data-parent="#accordion">
<div class="card-body p-1">
<div class="row no-gutters">
<div class="col-9">
<div class="row m-0 p-0 ">
<div class="col-sm">
<div class="row">
<div class="col text-center">
<small><strong>Start:</small></strong><br>30 May 08:00
</div>
<div class="col text-center">
<small><strong>Late/Expire:</small></strong><br>30 Jun 16:00
</div>
</div>
</div>
<div class="col-sm">
<div class="row">
<div class="col text-center">
<small><strong>Category</small></strong><br>Catering
</div>
<div class="col text-center">
<small><strong>Reward:</small></strong><br>300
</div>
</div>
</div>
</div>
</div>
<!-- Here is the button I can't seem to click -->
<div class="col-3 p-1 align-self-center"><strong>View Chore</strong></div>
</div>
</div>
</div>
</div>
Oddly enough, when I put the snippet and run it on stack overflow, it works fine. But when I run it in my browser, clicking anywhere in the card-body hides the collapse element.
Thanks for the help
Seth
Never mind, I found it. The "stretched-link" in the card header is making the whole card, including the body a stretched-link. For some reason the stack overflow snippet doesn't do that but the Chrome browser does.