when I use the bootstrap's modal like this:
<style>
.modal-content {
border-radius: 60px;
}
</style>
<div id="upload-loading" class="modal" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button id="loadingClose" type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Upload in progress...</h4>
</div>
</div>
</div>
</div>
it shows an underline
I tried to add this style
<style>
.modal-content, .modal-content * {
text-decoration: none !important;
}
</style>
but it doesn't seem to make any difference..
.modal-content {border: 0px solid rgba(0, 0, 0, 0.2);}
Just give border to the class .modal-header
I just solve it in React
<div>
{/* Button trigger modal */}
<button type="button" className="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
Launch demo modal
</button>
{/* Modal */}
<div className="modal fade" id="exampleModalCenter" tabIndex={-1} role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div className="modal-dialog modal-dialog-centered" role="document">
<div className="modal-content">
<div className="modal-header" style={{border:"1px solid #fff"}}>
<h5 className="modal-title" id="exampleModalLongTitle">Buy Premium</h5>
<button type="button" className="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div className="modal-body">
<p>Your account is limited to only 3 CV views.
To review more, purchase Premium Subscription</p>
<button className="btn btn-primary">Purchase</button>
</div>
<div className="modal-footer">
<button type="button" className="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Related
I am using Bootstrap 5.1.3 and I would like to blur the background when a modal opens with the CSS backdrop-filter property.
The simplest approach I tried is:
.modal-backdrop {
backdrop-filter: blur(5px);
}
Live demo here: https://codepen.io/kikosoft/pen/YzjxOQm
I am using the latest Firefox browser, but the results are the same in Chrome (Windows 11).
I tried many variants suggested everywhere, but none of them work. The background simply never gets blurred. Can anybody get the background to blur with backdrop-filter? What am I missing here?
You need to change in CSS and HTML structure according below code.
Using backdrop-filter
.modal-open .modal-backdrop {
backdrop-filter: blur(5px);
background-color: rgba(0, 0, 0, 0.5);
opacity: 1 !important;
}
<script src="//cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js"></script>
<link href="//cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<h1>This text should get blurred when the modal is opened.</h1>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Using filter
.modal-open .main-wrapper {
filter: blur(5px);
}
<script src="//cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js"></script>
<link href="//cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="main-wrapper">
<h1>This text should get blurred when the modal is opened.</h1>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
i dont have enough rep for comment so i write my answer here:
you should apply your style to #exampleModal
#exampleModal {
backdrop-filter: blur(5px);
}
The following code doesn't show the modal on button click, on mobile devices, when the button have an inline style float rule:
<button class="aa-secondary-btn" style="float: left; width: 140px;" title="Add a new product." data-toggle="modal" data-target="#modal">Add New</button>
<!--add product modal-->
<div class="modal fade" tabindex="-1" id="modal" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add New Product</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
<!--/add product modal-->
It's only when I remove the float rule that the modal shows. What should I do to have the button float and have the modal show on mobile devices?
By using Meshu's suggestion I solved my problem and now the modal shows. Actually, the button is clickable. Below is the solution code:
<button class="aa-secondary-btn" style="position: relative; z-index: 20;width: 140px; float: right;" title="Add a new product." data-toggle="modal" data-target="#add_prod_mod">Add New</button>
<!--add product modal-->
<div class="modal fade" tabindex="-1" id="add_prod_mod" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add New Product</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
The modals in the project seems to have broke for some reason. It worked a few days ago now it seems it broke. The container div is overflowing.
This is a sample html I've been using after all the modals broke
<!-- Modal -->
<div id="regHomeModal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal Header</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="container" style="border-style: dotted; border-color: black;">
<div class="row" style="border-style: dotted; border-color: red;">
<div class="col-sm-9">
<btn class="test btn btn-info btn-block btn-lg">TEST BUTTON</btn>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
That's happening because bootstrap already has an inbuilt '.container' class which has its width predefined, try changing the class name and check.
I have a bootstrap modal on my web page, but each time I open the modal, it opens below its shadows, how can I resolve this?
<div id="logoutModal" bsModal #myModal="bs-modal" class="modal"
tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-
hidden="true" >
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Sign Out</h4>
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true" aria-label="Close">×</button>
</div>
<div class="modal-body">
<p><i class="fa fa-question-circle"></i> Are you sure you
want to sign out? <br /></p>
</div>
<div class="modal-footer text-center">
<button class="btn btn-default btn-primary" data-
dismiss="modal" (click)="confirmSignOut()">Sign out</button>
<button class="btn btn-default" data-
dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
i have the solution now.
1. in my custom css file
.modal-backdrop {
//hides the default modal shadow
display: none;
}
.modal {
//modal custom bachground/shadow
background: rgba(0,0,0,0.5);
}
or
.modal{
background-color: rgba(0, 0, 0, 0.3);
}
.modal-backdrop{
position: relative;
}
2. i write my modal html tag as follow.
<div id="logoutModal" bsModal #myModal="bs-modal" class="modal"
tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-
hidden="true" data-backdrop="false" style="background:
rgba(0,0,0,0.5);">
....
</div>
and that solved my issue.
This could happen when the modal is not a direct child of <body>.
screenshot of the page
Hi, i'm losing my head trying to figure it out why this modal is shown like this. The code i followed was copied from the bootstrap website.
Here it is
<button type="button" class="btn btn-info btn-lg" (click)="showPerformedActivityModal()">Show Performed Activities</button>
<!--Modal -->
<div class="container">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"
[ngStyle]="{'display': myModalIsOpen ? 'block' : 'none', 'opacity': 5}">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<app-table [config]="config" [columns]="columns" [entity]="entity" [sort]="sort" [sortOrder]="sortOrder">
</app-table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="refreshResources()">Select Activities</button>
<button type="button" class="btn btn-default" (click)="closeModal()">Close</button>
</div>
</div>
</div>
</div>
</div>
This does the job : http://jsfiddle.net/sRmLV/1140/
You need to use new DIV and custom CSS, change the class 'modal-dialog-centered' by 'vertical-align-center'
HTML
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Launch demo modal</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="vertical-alignment-helper">
<div class="modal-dialog vertical-align-center">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">...</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
CSS
.vertical-alignment-helper {
display:table;
height: 100%;
width: 100%;
pointer-events:none;}
.vertical-align-center {
/* To center vertically */
display: table-cell;
vertical-align: middle;
pointer-events:none;}
.modal-content {
/* Bootstrap sets the size of the modal in the modal-dialog class, we need to inherit it */
width:inherit;
max-width:inherit; /* For Bootstrap 4 - to avoid the modal window stretching
full width */
height:inherit;
/* To center horizontally */
margin: 0 auto;
pointer-events:all;}