justify content center within modal not working - html

I am trying to use the justify-content-center within a modal but for some it does not render like it should..
I am trying to render a button in the middle of a div
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<img class="card-img-top" src="{% static "images/manager_happy.png"%}" alt="Card image cap">
<div class="modal-body">
<h5>Improve your managerial skills by understanding who is in your team</h5>
<hr>
<div class="container">
<div class="row">
<div class="col">
<div class="price-modal-container">
<span class="modal-price-title">Price:</span><span class="modal-price">60$</span><span class="modal-Oprice">299$</span><span class="modal-discount">60% off</span>
</div>
<div class="time-price">
<i class="far fa-clock fa-spin"></i>Limited time offer discount
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col">
<span class="glyphicon glyphicon-plus"></span> Add Credit Now
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<span class="glyphicon glyphicon-plus"></span> Add Credit Now
</div>
</div>
</div>
</div>
Any idea it does not work ? is there any trouble because of the modal ?

Are you trying to render it so the button is horizontally centered? Right now it's not working because the col class takes up all the remaining width. So you can either make the content inside the column centered or make it so the column itself doesn't take up the full width.
To center the content inside the column you just need add the text-center class either to the column or by simply replacing justify-content-center on the row.
<div class="row text-center">
<div class="col">
<span class="glyphicon glyphicon-plus"></span> Add Credit Now
</div>
</div>
Alternatively you can keep the row the way it is and change the column class from col to col-auto so it won't take the full width.
<div class="row justify-content-center">
<div class="col-auto">
<span class="glyphicon glyphicon-plus"></span> Add Credit Now
</div>
</div>

Related

Bootstrap fullscreen modal not working when trying to implement it with Laravel

I'm trying to display a section of my about page using a full screen modal but the modal is only opening/ showing in a small section. It only opens up a little bit when I use 'modal-dialog modal-lg' but it doesn't expand besides that. Can anyone help me fix this issue?
<!--1-->
<div class="site-section">
<div class="container">
<div class="row align-items-center mr-5">
<div class="col-lg-6 py-5 px-5">
<img src="assets/img/bee.jpg" alt="image" class="img-fluid rounded" style="width:500px;height:500px;">
</div>
<div class="col-lg-6 pl-lg-5 ">
<h3 class="mt-4 font-weight-bold">About Us</h3>
<p class="text-justify pt-0 mr-5"> is a publishing company working with a non- denominational ministry.
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Load More
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-fullscreen-xxl-down">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
Try change your bootstrap class form this :
<div class="modal-dialog modal-fullscreen-xxl-down">
To this :
<div class="modal-dialog modal-fullscreen">
Also be sure that you have Bootstrap version 5 installed in your laravel project. Fullscreen modals are only included by default in Bootstrap 5 not in the previous ones: https://getbootstrap.com/docs/5.0/components/modal/#fullscreen-modal

How do you constrain the size of elements to the size of the modal dialog?

I am making an anuglar app and I make use of bootstrap 3 modal dialogs to display images. I'd like to limit the size of the images to to the size of the modal dialog without setting the width and height of the images since the images currently extend over the dialog. Here is what I mean:image
Below is my template code. I'm a novice at template designs so any tips and suggestions would also be much appreciated!
<div class="modal modal-backdrop" tabindex="-1" [ngStyle]="{display: floorPlanChooseDialogShow ? 'block' : 'none'}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">
<h5>
Choose your floor plan.
</h5>
</div>
</div>
<div class="modal-body">
<form #f="ngForm">
<div class="container" style="width: 700px;" id="fpImages">
<div class="row">
<div class="col-xl-6 col-lg-6 col-md-6" id="fpimg">
<img src="../../assets/img/Versailles 3D FP.jpg" alt="">
</div>
<div class="col-xl-6 col-lg-6 col-md-6" id="fpimg">
<img src="../../assets/img/Versailles 3D FP.jpg" alt="">
</div>
</div>
<div class="row">
<div class="col-xl-6 col-lg-6 col-md-6" id="fpimg">
<img src="../../assets/img/Barcelona Combined.jpg" alt="">
</div>
<div class="col-xl-6 col-lg-6 col-md-6" id="fpimg">
<img src="../../assets/img/Bourdeaux.jpg" alt="">
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="onToggleChooseFloorPlanDialog()">
Submit
</button> |
<button type="button" class="btn btn-warning" (click)="onToggleChooseFloorPlanDialog()">
Cancel
</button>
</div>
</div>
</div>
You can use the background-size property to make the image fit in the modal.
background-size: 100% 100%;
Here is a working Demo on Stackblitz.
Use the "img-fluid" class of the bootstrap
<img class="img-fluid m-0 p-0" src="exemplo.com">
https://getbootstrap.com/docs/4.0/components/modal/
https://getbootstrap.com/docs/4.0/content/images/
I got it to work. I just used 'img-responsive" class.
<div class="modal-body">
.....
<div class="col-xl-6 col-lg-6 col-md-6 col-sm-6"
id="fpimg"
data-toggle="tooltip"
data-placement="top"
title="Lourdes"
>
<img class="img-responsive" src="../../assets/img/Lourdes 1 3D fP.jpg"
name="lourdes"
(click)="selectedFloorPlan($event)"
>
</div>
.....
</div>

Data is not getting binded to the modal

Thank you for reading this question.
Iam opening the modal from typescript code after some API success reponse.
It is binding normally after taking more time eventhough if iam not using timer.
Main thing is that if I inspect it wil show the modal data (dont know may be becouse scroll or refresh) and even if i wont mention timer also it wil bind very next after i inspect.
i just wanted to clarify i have used timer becouse after i inspect may be a scroll or refresh it was binding suddenly, i thought may be a symultaneous process of value assgn and opening a modal.
This my html
<div style="display: none">
<button class="primary" #myModalSuccess data-target="#myModalSuccess" data-toggle="modal"
style="cursor: pointer;">Delete</button>
<div id="myModalSuccess" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content" *ngIf="checkOutConfFromRazor">
<div class="modal-header">
<button type="button" (click)="checkSubscriptionAndInvitee()" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="text-center"><img style="height: 80px; " src="assets/img/dashboard/check_circle.svg"></div>
<div class="modal-body">
<h4 class="text-center primary">Payment successful</h4>
<p class="text-center location-text ">Your payment has been proccessed! <br>Details of your transaction are
listed below.
</p>
<div class="ver-divider"></div>
<div class="hor-line"></div>
<div class="ver-divider"></div>
<p class="text-center primary">Transaction ID : <span
class="text-right">{{checkOutConfFromRazor?.id}}</span> </p>
<div class="ver-divider"></div>
<div class="row">
<div class="col">
<label>Transaction Amount</label>
</div>
<div class="col text-right">
<label> {{checkOutConfFromRazor?.amount | slice:0:checkOutConfFromRazor?.amount?.length-2}}
₹</label>
</div>
</div>
<div class="ver-divider"></div>
<div class="hor-line"></div>
<div class="ver-divider"></div>
<div class="row">
<div class="col">
<label>Transaction date</label>
</div>
<div class="col text-right">
<label>{{checkOutConfFromRazor?.created_at | date}}</label>
</div>
</div>
<div class="text-center mt-4">
<button (click)="checkSubscriptionAndInvitee()" class="primary-button-big pl-5 pr-5 pt-1 pb-1"
data-dismiss="modal" style="border: none;">Close</button>
</div>
</div>
</div>
</div>
This is my .ts code
this.subscription = this.userService.verifyCheckOut(val.planId, JSON.stringify(response)).subscribe(value => {
if (value.isVerifyed) {
this.checkOutConfFromRazor = value.payment;
console.log("sucessData" + JSON.stringify(this.checkOutConfFromRazor));
setTimeout(() => {
this.myModalSuccess.nativeElement.click();
}, 20000);
} else {
this.checkOutConfFromRazor = value.payment;
this.myModalFailure.nativeElement.click();
}
});

close button on right of text-centered breadcrum with Bootstrap

So I am trying to create a modal with a centered breadcrum on top and a close button on the very right, on the same line of the breadcrum.
I am using Bootstrap 3
Here is my code:
<div class="modal container">
<div class="modal-content col-sm-6 col-sm-offset-3">
<div class="row text-center">
<div class="breadcrumb-container">
<ol class="breadcrumb modal-breadcrum">
<li class="breadcrumb-step step-one">Abonnement</li>
<li class="breadcrumb-step step-two">Inscription</li>
<li class="breadcrumb-step step-three">Paiement</li>
</ol>
<button type="button" class="close" aria-label="Close">
<span id="close-btn" aria-hidden="true">×</span>
</button>
</div>
</div>
</div>
</div>
With this, The breadcrum is at its rights place, centered on top of the modal.
But the close button is also centered, wrapped under the breadcrum.
How can I achieve this ?
What I actually want is:
<!-- some space here --> centered Breadcrum <!-- some space here --> X
OK so after some research, I found a good solution:
simply put the button out of the row, actually before the breadcrum row:
<div class="modal container">
<div class="modal-content col-sm-6 col-sm-offset-3">
<button type="button" class="close" aria-label="Close">
<span id="close-btn" aria-hidden="true">×</span>
</button>
<div class="row text-center">
<div class="breadcrumb-container">
<ol class="breadcrumb modal-breadcrum">
<li class="breadcrumb-step step-one">Abonnement</li>
<li class="breadcrumb-step step-two">Inscription</li>
<li class="breadcrumb-step step-three">Paiement</li>
</ol>
</div>
</div>
</div>
</div>
Notice that, as #Minal Chauhan mentionned, the button must have the float: right property, and he bootstrap close class gives it to the button.

Modal behaving abnormally

I am trying to build a two column layout in a bootstrap modal. This is the code:
<div class="modal fade in" id="product-showcase-modal" tabindex="-1" role="dialog" aria-labelledby="product-showcase" aria-hidden="false" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="container col-xs-12">
<div class="row-fluid">
<div class="col-xs-6">
<img src="http://localhost/haya/img/hijabs/dark%20grey.jpg" id="product_image" width="200px" height="auto" style="display: inline;">
</div>
<div class="col-xs-6">
<h3 id="product_name">Dark Gray</h3>
<p id="new_price">$3.00</p>
<p style="text-decoration: line-through;" id="old_price">$4.35</p>
<button class="btn btn-warning">Add to cart</button>
</div>
</div>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
And this is the result:
I have no idea why is this happening. Can anyone resolve this?
UPDATE 1:
I removed the col-xs-12 class from the container div. Now the container is in the modal's body but it's has taken a width of 100% (my screen's width). Result:
Just need to add a clearfix to the modal-body. This will fix the float item issue where the container doesn't fully expand.
Fiddle: http://jsfiddle.net/52VtD/6310/
<div class="modal-body clearfix">