I would like to create a collapsible "card" with a row of buttons on the lower part of the collapsible div. A bit like a twitter card which has a row of buttons on the lower side. In this example, the card itself is clickable (and I would like it to be collapsible). In my case, I would like there to be a little arrow on the right had side that indicates whether the collapsible div is folded or unfolded. Moreover, I would like to write multiple paragraphs within the collapsible div (above the row of buttons).
I tried several things, but I haven’t figured out how to do this. It shouldn’t be too hard, but I’m not a very good coder so I would appreciate it very much if somebody could help.
I already tried the following with bootstrap
.block {
position:relative;
}
.block .overlay {
position:absolute;
left:0; top:0; bottom:0; right:0;
}
.block .inner {
position:relative;
pointer-events: none;
z-index: 1;
}
.block .inner a {
pointer-events: all;
}
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<div class="accordion-item">
<div class="accordion-button block " type="button">
<a class="overlay" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample"></a>
<div class="inner">
<p>This entire box is collapsible.</p>
<p>But somehow the arrow on the right side does not turn</p>
<a href="https://duckduckgo.com/">I'm a clickable link that could also have been a button</a>
</div>
</div>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Exra information about the thing written above.
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
The arrow on the right hand side is unfortunately not clickable and does not rotate.
2
Answers
this is an example of collapsing, but if you want to redirect the clicker to the author’s page, he’ll not see the collapsing
EDIT: if you want to set the collapsing on a button inside the card, just change the event listener to it BUT not the class toggling
ANOTHER EDIT:
to use it in bootstrap, you can customize it
if you want to set the collapsing on a button inside the card, just add these attributes
data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample"
to the buttonI suggest to you to read this page of Bootstrap docs:
https://getbootstrap.com/docs/5.1/components/collapse/
Here there is all you need.