Putting a button inside a collapsing card in Bootstrap - html

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.

Related

"scroll to" with 2 scroll-able contents at once? (using bootstrap 5.2)

I have 2 "contents" in their divs next to each other. 1) is a slim categorized link list with buttons loading the content on 2). When there is nothing loaded yet on 2) it shows you an overview of the same listed items in 1) with little more information as cards.
Now, after I am having so many buttons I need to show in 1), I made the list scroll-able and added jump-to buttons, so that the user doesn't have to scroll to the bottom to reach the last category of the list. Logically 2) is scroll-able as well, as this is the main content of the site, respectively showing the big cards as an overview.
How do I realize to have the jump-to buttons working for both scroll-able divs at once? And is there maybe a solution without js, since I have absolutely no idea about js coding?
The only thing I am getting to work is only one of both divs jump-to-able
Btw. I am using bootstrap 5.2 . But unfortunately I didn't find a solution to that problem in their docs either :/
I also tried the documented anchors via scrollspy without success ( https://getbootstrap.com/docs/5.2/components/scrollspy/#usage )
Thank you very much in advance for any help!
in CodePen
https://codepen.io/KeenaBiacym/pen/qBYaLVQ
The scroll list
<div id="content">
<div class="container p-5 pt-3">
<div class="gallery d-flex">
<v class="btncontainer gallery nav justify-content-end">
<div class="scrollbar stickynator gallery">
<div class="slidebtn_galtab active" id="tab0" data-bs-toggle="tab" data-bs-target="#tab0-pane" type="button" role="tab" aria-controls="tab0-pane" aria-selected="true">
Overview
</div>
<div class="text-center pt-4">
▼ Category2 ▼
</div>
<h3 class="pt-4 text-center content-title" id="content_cat1">Category1</h3>
<div class="slidebtn_galtab mt-3" id="tab1" data-bs-toggle="tab" data-bs-target="#tab1-pane" type="button" role="tab" aria-controls="tab1-pane" aria-selected="false" style="width:400px">
Title1
</div>
<div class="slidebtn_galtab mt-3" id="tab2" data-bs-toggle="tab" data-bs-target="#tab1-pane" type="button" role="tab" aria-controls="tab1-pane" aria-selected="false" style="width:400px">
Title2
</div>
<br><br><br><br>
<h3 class="pt-4 text-center content-title" id="content_cat2">Category2</h3>
<div class="slidebtn_galtab mt-3" id="tab3" data-bs-toggle="tab" data-bs-target="#tab1-pane" type="button" role="tab" aria-controls="tab1-pane" aria-selected="false" style="width:400px">
Title1
</div>
<div class="slidebtn_galtab mt-3" id="tab4" data-bs-toggle="tab" data-bs-target="#tab1-pane" type="button" role="tab" aria-controls="tab1-pane" aria-selected="false" style="width:400px">
Title2
</div>
<div class="text-center pt-4">
▲ Category1 ▲
</div>
</div>
Content
<div class="tab-content container" id="TabContent">
<!-- CONTENT 0 -->
<div class="tab-pane fade active show" id="tab0-pane" role="tabpanel" aria-labelledby="tab0" tabindex="0">
<div class="container" id="content_cat1"><h3 class="pb-3 text-center content-title">Category1</h3>
<div class="row row-cols-1 row-cols-md-3 g-4 allcards">
<div class="col" id="gallerytablink1">
<div class="card mozoom h-100">
<div class="card-img-top moopacity cardsoverview">
<img src="https://images.unsplash.com/photo-1665597652829-bf80107d7045?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NjYwOTgzNDI&ixlib=rb-1.2.1&q=80&w=400" class="card-img-top">
</div>
<div class="card-body">
<h5 class="card-title">Title1</h5>
<p class="card-text">Subtitle1</p>
</div>
<div class="card-footer">
<small class="text-muted">img1desc</small>
</div>
</div>
</div>
<div class="col" id="gallerytablink2">
<div class="card mozoom h-100">
<div class="card-img-top moopacity cardsoverview">
<img src="https://images.unsplash.com/photo-1665597652829-bf80107d7045?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NjYwOTgzNDI&ixlib=rb-1.2.1&q=80&w=400" class="card-img-top">
</div>
<div class="card-body">
<h5 class="card-title">Title2</h5>
<p class="card-text">Subtitle2</p>
</div>
<div class="card-footer">
<small class="text-muted">img2desc</small>
</div>
</div>
</div>
</div>
<div class="container" id="content_cat2"><h3 class="pb-3 text-center content-title">Category2</h3>
<div class="row row-cols-1 row-cols-md-3 g-4 allcards">
<div class="col" id="gallerytablink3">
<div class="card mozoom h-100">
<div class="card-img-top moopacity cardsoverview">
<img src="https://images.unsplash.com/photo-1665597652829-bf80107d7045?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NjYwOTgzNDI&ixlib=rb-1.2.1&q=80&w=400" class="card-img-top">
</div>
<div class="card-body">
<h5 class="card-title">Title1</h5>
<p class="card-text">Subtitle1</p>
</div>
<div class="card-footer">
<small class="text-muted">img1desc</small>
</div>
</div>
</div>
<div class="col" id="gallerytablink4">
<div class="card mozoom h-100">
<div class="card-img-top moopacity cardsoverview">
<img src="https://images.unsplash.com/photo-1665597652829-bf80107d7045?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NjYwOTgzNDI&ixlib=rb-1.2.1&q=80&w=400" class="card-img-top">
</div>
<div class="card-body">
<h5 class="card-title">Title2</h5>
<p class="card-text">Subtitle2</p>
</div>
<div class="card-footer">
<small class="text-muted">img2desc</small>
</div>
</div>
</div>

Why does my Bootstrap stretched link extend out several levels?

I am trying to stretched link for my nested div but it is including even parent. I need only listItem to be clickable but this makes entire card div clickable.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-xs-8">
<div class="col-xl-12 col-md-12 mb-3 mt-2">
<div class="card custom-bg-2 h-100">
<div class="card-header bg-secondary">
<h3 class="fw-bold text-white text-center">Page Title</h3>
</div>
<div class="card-body">
<div class="listItem">
<img src="https://via.placeholder.com/100" class="rounded" alt="Title">
<p><span class="badge bg-secondary text-light" style="font-size: large;">Title</span></p>
<p><span class="badge bg-secondary ms-2">Views</span></p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="row">
<div class="col-xl-12 col-md-8 mb-3 mt-2">
<div class="card custom-bg-2 h-100">
<div class="card-header bg-secondary">
<h3 class="fw-bold text-white">Category</h3>
</div>
<div class="card-body">
....
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Per the Bootstrap docs (and the fundamental rules of absolute positioning), stretched links apply to the nearest element with non-static positioning. You can put the position-relative class on the parent to make that so.
I've also replaced your inline font size styles with the lead class on the parent paragraph. Just don't use inline styles, especially when your style library provides typography classes for that.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-xs-8">
<div class="col-xl-12 col-md-12 mb-3 mt-2">
<div class="card custom-bg-2 h-100">
<div class="card-header bg-secondary">
<h3 class="fw-bold text-white text-center">Page Title</h3>
</div>
<div class="card-body">
<div class="listItem position-relative">
<img src="https://via.placeholder.com/100" class="rounded" alt="Title">
<p class="lead"><span class="badge bg-secondary text-light">Title</span></p>
<p><span class="badge bg-secondary ms-2">Views</span></p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="row">
<div class="col-xl-12 col-md-8 mb-3 mt-2">
<div class="card custom-bg-2 h-100">
<div class="card-header bg-secondary">
<h3 class="fw-bold text-white">Category</h3>
</div>
<div class="card-body">
....
</div>
</div>
</div>
</div>
</div>
</div>
</div>

How to set the backgroundcolor of a Bootstrap card fo the whole column?

I've got a questtion about the Bootstrap Card Deck.
I create a Card Deck with two cards in a row. On the first card I've got some text under the header and in the second card there is no text under the header. In this case the grey color does not fill the whole card as you can see in the example. How can I fix it, that the hole column is also grey?
Thanks for your help!
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<p class="font-weight-light text-muted mb-2">Some text</p>
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2">No text</p> -->
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">50</p>
</div>
</div>
</div>
</a>
</div>
If you want to have the height be equals the container, you can use h-100 on the div row mx-0.
More information can be found here: https://getbootstrap.com/docs/4.0/utilities/sizing/
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<p class="font-weight-light text-muted mb-2">Some text</p>
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2">No text</p> -->
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal"></p>
</div>
</div>
</div>
</a>
</div>
Ideally you should not play around with left/right margins of row and col in bootstrap. You should use no-gutters class with row to have the effect you want. Additionally, you should add h-100 on the second row to take full height. Also a better way to center align your number is like I have done in the snippet by using justify-content-center d-flex align-items-center.
Also your code was missing a container element so that scrollbar was coming in your snippet. I have added that too.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="container">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 no-gutters">
<div class="col-md-8 grey lighten-4 rounded-left">
<h5 class="font-weight-bold p-2">Header</h5>
<p class="font-weight-light text-muted mb-2 px-2">Some text</p>
</div>
<div class="col-md-4 text-center justify-content-center d-flex align-items-center">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 no-gutters">
<div class="col-md-8 grey lighten-4 rounded-left">
<h5 class="font-weight-bold p-2">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2 px-2">No text</p> -->
</div>
<div class="col-md-4 text-center justify-content-center d-flex align-items-center">
<p class="h2 font-weight-normal">50</p>
</div>
</div>
</div>
</a>
</div>
</div>
Please check the code differences https://i.stack.imgur.com/0Q2IX.png
Using anchor tag as it will not consider a height and width so you have to set a class in card-body using this class="card-body p-0 grey lighten-4".
Remove the class "grey lighten-4" from class="col-md-8 rounded-left pt-2" & set to class="card-body p-0 grey lighten-4"
.grey {
background-color: #f5f5f5 !important;
}
/*OR*/
.grey.lighten-4 {
background-color: #f5f5f5 !important;
}
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0 grey lighten-4">
<div class="row mx-0">
<div class="col-md-8 rounded-left pt-2">
...
</div>
<div class="col-md-4 text-center pt-3">
...
</div>
</div>
</div>
</a>
</div>

Collapse/Expand animation for panel to edit

I have a panel that shows a task. The tasks are being displayed by iterating through an array.
When a task is clicked, I want the panel to expand and show a form which allows the user to edit the clicked task.
How can I realize this behavior?
The panel has already an animation allocated to itself, namely a delete animation. How can I additionally add an expand/collapse animation - and how do I make sure that the edit field is allocated to the task clicked.
<div class="row content-cont" [#EnterLeave]="animation">
<div class="col-11 d-flex todo shadow-sm">
<div class="row w-100 align-self-center">
<div class="col-2 px-0 d-flex justify-content-center">
<button type="button" class="btn btn-default btn-circle shadow-sm exceeded align-self-center" [ngClass]="'state' + task.state"
(click)="updateState(task.id)"></button>
</div>
<div class="col-6 px-0">
<div class="row">
<div class="col-6 d-flex">
<h1 class="align-self-center">{{task.title}}</h1>
</div>
<div class="col-6 d-flex">
<p class="desc align-self-center">{{task.describtion}}</p>
</div>
</div>
<div class="row">
<div class="col-4">
<p *ngIf="task.date !== null">{{task.date | date: 'dd.MM.yyyy'}}
</p>
</div>
</div>
</div>
<div class="col-4 d-flex justify-content-end">
<img *ngIf="task.state !== '2'" class="align-self-center trash-button" src="/assets/icons/trash-2-colorized.svg" alt="Trash" (click)="deleteTask(task.id)">
<img *ngIf="task.state === '2'" class="align-self-center" src="/assets/icons/trash-2.svg" alt="Trash">
</div>
<h1 class="priority position-absolute">{{task.priority}}</h1>
</div>
</div>
</div>

Create image grid - bootstrap4

I'm trying to create an image grid with that little space between columns equal to the image below:
The problem is that I can not make the right margin(red line), image below shows the problem:
JSfiddle: https://jsfiddle.net/castordida/0zy7qd5m/
<div class="container gridhome mt-5 mb-5 p-0">
<div class="row" style="height:469px;">
<div class="col-sm-8 h-100" style="background-color:#000;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
<div class="col-sm-4 h-100 p-0">
<div class="col-sm-12 h-50 p-0">
<div class="h-100 ml-1" style="background-color:#919191;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
</div>
<div class="col-sm-12 h-50 p-0">
<div class="h-100 ml-1 mt-1" style="background-color:#919191;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
</div>
</div>
</div>
<div class="row mt-1" style="height:234.5px;">
<div class="col-sm-4 h-100 p-0">
<div class="h-100" style="background-color:#919191;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
</div>
<div class="col-sm-4 h-100 p-0">
<div class="h-100 ml-1" style="background-color:#919191;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
</div>
<div class="col-sm-4 h-100 p-0">
<div class="h-100 ml-1" style="background-color:#919191;">
<span class="categoria">test</span>
<h3>TESTE</h3>
</div>
</div>
</div>
</div>
Ok it's due to the fact there is a gab between your picture at right... But the fixed height doesn't mention it...
There are many ways to correct this...
First : https://jsfiddle.net/y0x7kpza/
Add an overflow:hidden to the first .row
Second: https://jsfiddle.net/d0a52xwk/
Reaffect the height of the two div on the right in taking care of the margin-top of these elements.
.h-50-bis{
height:calc(50% - 0.125rem);
}