Align components using angled bootstrap - html

I'm trying to generate a component aligned in the middle, as follows:
<app-card titulo="Painel ao Vivo" [zeroPadding]="false" icon="fa-heartbeat fas">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="justify-content-center">
<span class="text-sm text-black font-weight-bold mr-2">{{jogo.timeCasa.nome}}</span>
<app-avatar [titulo]="jogo.timeCasa.nome" [img]="jogo.timeCasa.logo"
class="avatar rounded-circle bg-primary mr-2"></app-avatar>
<button type="button" class="btn btn-primary btn-sm">0</button>
<button type="button" class="btn btn-primary btn-sm">0</button>
<app-avatar [titulo]="jogo.timeVisita.nome" [img]="jogo.timeVisita.logo"
class="avatar rounded-circle bg-primary mr-2"></app-avatar>
<span class="text-sm text-black font-weight-bold">{{jogo.timeVisita.nome}}</span>
</div>
</div>
</app-card>
app-card:
<div class="card">
<div class="card-header border-0" >
<h4 *ngIf="titulo" class="card-title"><i class="{{icon}}"></i> {{titulo}} </h4>
<ng-container *ngIf="header" [ngTemplateOutlet]="header"></ng-container>
</div>
<div class="card-body border-radius-bottom" [ngClass]="{'p-0': zeroPadding}">
<ng-content></ng-content>
</div>
</div>
How should it look: https://i.stack.imgur.com/NfuKw.png, how was it on the web: https://i.stack.imgur.com/cwKmq.png, how was it on the mobile: https://i.stack.imgur.com/RR6GP.png

Related

Bootstrap 5 Hero

I am unable to figure out what classes should I add/remove to achieve the same image positioning as in the preview of the Bootstrap Border hero with cropped image and shadows.
My image doesn't sit on the edge of the hero and it looks even worst on mobile scale. Here is what my hero looks like now:
<div id="support" class="hero-donate container my-5">
<div class="row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg">
<div class="col-lg-7 p-3 p-lg-5 pt-lg-3">
<h1 class="display-4 fw-bold lh-1">Find out more and support our work</h1>
<p class="lead">Text</p>
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
<button type="button" class="btn btn-outline-danger btn-lg px-4 me-md-2 fw-bold">DONATE</button>
<button type="button" class="btn btn-secondary btn-lg px-4">Volunteer</button>
</div>
</div>
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden">
<img class="rounded-lg-3 shadow-lg" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" alt="" width="75%">
</div>
</div>
</div>
Solutions for both
The image in example is an horizontal image hence it fits perfectly on the right end of div. Your image is vertical so apply this class : float-end on image tag.
For mobile view. Your code works fine only image alignment is distorted. for which apply w-100 and m-auto to image tag. your updated image tag will look like :
<img class="rounded-lg-3 shadow-lg float-end m-auto w-100" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" alt="" width="75%">
here is the working snippet
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet"/>
<div id="support" class="hero-donate container my-5">
<div class="row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg">
<div class="col-lg-7 p-3 p-lg-5 pt-lg-3">
<h1 class="display-4 fw-bold lh-1">Find out more and support our work</h1>
<p class="lead">Text</p>
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
<button type="button" class="btn btn-outline-danger btn-lg px-4 me-md-2 fw-bold">DONATE</button>
<button type="button" class="btn btn-secondary btn-lg px-4">Volunteer</button>
</div>
</div>
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden">
<img class="rounded-lg-3 shadow-lg float-end m-auto w-100" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8" alt="" width="75%">
</div>
</div>
</div>

how can i align my paragraph tag in the center?

How would i align
<p className="display-4 fw-bolder mb-4 text-center text-white" >Title</p>
vertically and horizontally?
<div>
<section id='vision'>
<div className="container">
<div className="row justify-content-center">
<div className="col-md-8 mt-5">
<h1 className="display-4 fw-bolder mb-4 text-center text-white"> </h1>
<p className="display-4 fw-bolder mb-4 text-center text-white" >Title</p>
<div className='buttons d-flex justify-content-center'>
{/* <button className='btn btn-outline-primary rounded-pill px-4 py-2 ms-2'>Learn More</button>
<button className='btn btn-outline-primary rounded-pill px-4 py-2 ms-2'>Buy Now</button> */}
</div>
</div>
</div>
</div>
</section>
<History />
{/* <Product/> */}
{/* <Service/> */}
{/* <Contact/> */}
</div>

Fill row content with an image keeping the size

My problem is in containing the images within a bootstrap row. When I add the image this is not contained adapting to the size of the row but for some reason it follows its size by activating the scroll.
I would like the image to fit into the container without causing scrolling when resizing the image.
This is the correct behavior when not adding any elements in the row:
<div class="container-fluid">
<div class="row justify-content-center min-vh-100 pt-3 ps-3 pb-3">
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
While this is the behavior when I add an image:
<div class="container-fluid">
<div class="row justify-content-center min-vh-100 pt-3 ps-3 pb-3">
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive w-100 h-100 px-0 rounded" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive w-100 h-100 px-0 rounded" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
</div>
</div>
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can use a trick sizing image to an height of 0 and a min-height of 100%
style="height:0;min-height:100%;" or via a custom class (better practice)
idea:
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row justify-content-center min-vh-100 mh-100 pt-3 ps-3 pb-3">
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100 ">
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive px-0 rounded" style="height:0;min-height:100%;" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive px-0 rounded" style="height:0;min-height:100%;" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
</div>
</div>
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Another possibility is also to set a max-height on the conatiners
other possible example:
.max-vh-100{max-height:calc(100vh - 2em);}/* takes into account : pt-3 p-s3 pb-3 that could be turned into p-3 */
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row justify-content-center min-vh-100 p-3">
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100 max-vh-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive w-100 h-100 px-0 rounded" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded " slot="1">
<img class="img-responsive w-100 h-100 px-0 rounded" src="https://www.logo.wine/a/logo/Stack_Overflow/Stack_Overflow-Logo.wine.svg">
</div>
</div>
</div>
<div class="col" style="background-color: rgba(0,0,0,.03);">
<div class="d-flex flex-column h-100 max-vh-100">
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
<div class="row flex-grow-1 h-50 slot border border-3 rounded" slot="1">
<div class="container-fluid d-flex " style="background-color: rgba(0,0,0,.03);">
<div class="align-self-center mx-auto">
<button type="button" class="btn btn-xs btn-icon btn-round btn-light new-stream-btn" slot="1">
<i class="fa fa-plus text-dark"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
.max-vh-100{max-height:calc(100vh - 2em);}takes into account : pt-3 ps-3 pb-3 that could be turned into p-3

Bootstrap 5 Tabs is not opening correctly

I want to make Vertical bootstrap tabs but when I tried to use the code from bootstrap 5 docs I faced a problem when opening the tabs as you can see in the screenshot the tabs are showing next to each other when I switch between them so what I'm missing in this
]
code
<div class="d-flex align-items-start center rounded" style="direction: rtl;">
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="btn btn-lg btn-primary" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home"
type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</button>
<button class="btn btn-lg btn-primary dflex" id="v-pills-profile-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile"
aria-selected="false">Store</button>
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
<div class="container contain bg-light rounded">
<div class="row" style="direction:rtl;">
<h4 class="title" >Home</h4><br>
</div><hr />
<div class="row" style="direction:rtl;">
<div class="card cashIncom shadow-lg p-3 mb-5 bg-white rounded">
<div class="card-body" style="width:750px;">
<div class="mb-1">
<div class="d-inline-flex align-items-center">
<span class="spanIncome">إجمالي الأرباح :</span>
<span class="spanValue" id="spanIncomeValue">500$</span>
<i class="fa-solid fa-credit-card iconstate"></i>
</div>
</div>
</div>
</div>
</div>
<div class="row" style="direction:rtl;">
<div class="card cashIncom shadow-lg p-3 mb-5 bg-white rounded">
<div class="card-body" style="width:750px;">
<div class="mb-1">
<div class="d-inline-flex align-items-center">
<span class="spanIncome">المصروفات :</span>
<span class="spanValuespent" id="spanIncomeValue">500$</span>
<i class="fa-solid fa-dollar-sign spenticon"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Getting button to align center in Bootstrap card footer

I am using Bootstrap 5.1.3 and trying to get a button to center in the footer of a card. Here's the code I'm using:
CSS
.btnStandard {
min-width: 10vw;
}
HTML
<div class="card-footer justify-content-center">
<button type="button" class="btn btn-labeled btn-success d-flex justify-content-between btnStandard">
<div class="col-10 text-start">Tell Me</div>
<div class="col-2 text-center"><i class="fa-solid fa-square-info"></i></div>
</button>
</div>
Nothing I've tried will let me center the button in the card footer. Any thoughts?
Try this as well:
<div class="card-footer mx-auto justify-content-center">
<button type="button" class="btn btn-labeled btn-success d-flex justify-
content-center btnStandard">
<div class="col-10 text-center">Tell Me</div>
<div class="col-2 text-center"><i class="fa-solid fa-square-info"></i>
</div>
</button>
</div>
Here you go... You forgot to add d-flex.
Change this...
<div class="card-footer justify-content-center">
<button type="button" class="btn btn-labeled btn-success d-flex justify-content-between btnStandard">
<div class="col-10 text-start">Tell Me</div>
<div class="col-2 text-center"><i class="fa-solid fa-square-info"></i></div>
</button>
</div>
...to this.
<div class="card-footer d-flex justify-content-center">
<button type="button" class="btn btn-labeled btn-success d-flex justify-content-between btnStandard">
<div class="col-10 text-start">Tell Me</div>
<div class="col-2 text-center"><i class="fa-solid fa-square-info"></i></div>
</button>
</div>