How to remove weird right margin of overflow-y: auto - html

So I've been trying to add a vertical scroll into my modal. It was a half-success.
The CSS and all are working fine but I'm having this weird margin-right that seems like can't be removed.
I tried to play around with the inspect element and nothing is working.
By the way, when I removed the overflow-y: auto the layout is okay (ofc, can't be scrolled)
So in my conclusion, the CSS overflow-y: auto is the one that creates that weird margin-right.
Can someone help me or explain this to me and How to remove it?
See the images attached for details.
PS. I think no need to post the code here since it's just CSS
/* View Menu-Modal */
.modalMenu {
float: none;
width: 100%;
height: 200px;
}
.modalMenu-img {
width: 100%;
height:100%;
object-fit:cover;
border-radius: 8px;
}
.modalPrice {
font-size: 24px;
line-height: 28px;
margin: 0px;
font-family: 'Barlow', sans-serif;
}
.modal-dialog {
height: 100% !important;
}
.modal-header {
border-bottom: 0px !important;
}
.modal-content {
border: 0px !important;
height: auto;
min-height: 80%;
border-radius: 12px;
}
.modal-body {
height: 70vh;
overflow-y: auto;
/*THIS IS WHERE THE SCROLL is, when I added this ofc it ads a vertical scroll but at the same time the annoying right-margin.*/
margin-right: 0px !important;
}
.modal-footer {
border-top: 0px !important;
}
#view-menu-modal::-webkit-scrollbar {
display:none
}
<!-- Modal -->
<div class="modal fade" id="viewMenuModal<?= $menu_id ?>" tabindex="-1" role="dialog" aria-labelledby="viewOrderModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="view-menu-modal"> <!--THIS IS WHERE THE OVERFLOW-Y: auto is applied -->
<div class="modalMenu mb-2">
<img class="modalMenu-img" src="images/img/stock/baby-back-ribs.jpeg" alt="blog-img">
</div>
<div class="content-right">
<h3><?= $menu_name ?></h3>
<p class="food-description"><?= $menu_desc ?></p>
<p class="modalPrice">₱ <?= $menu_price ?> </p>
</div>
</div>
<div class="modal-footer">
<!-- <button type="button" class="btn btn-lg btn-secondary" data-dismiss="modal">Close</button> -->
<button type="button" class="btn btn-lg primary-btnLink mb-1">Add to Order</button>
<button type="button" class="btn btn-lg secondary-ghostBtn" data-dismiss="modal" aria-label="Cancel">Cancel</button>
</div>
</div>
</div>
</div>
This is the screenshot of the weird right-margin produced by the overflow-y: auto
See how it looks like
And this is the elements panel, weird that there's no right-margin value.
Weird margin-right
Full Inspect Element Panel

If you want to say that you have added a vertical scrollbar but it automatically overflows in the x-axis. Then add this property also overflow-x: hidden it will remove spaces on the right side or will remove the horizontally scrollbar.

Try setting the overflow-y to overlay. This should make the scrollbar appear only as an overlay, thus not affecting the width of your element!
.modal-body{
overflow-y: overlay;
}

You can use overflow-y: scroll; on your modal body. I changed your height to 200px to demonstrate. Also, for the margin, try just margin-right: 0; instead of scroll-margin-right
/* View Menu-Modal */
.modalMenu {
float: none;
width: 100%;
height: 200px;
}
.modalMenu-img {
width: 100%;
height:100%;
object-fit:cover;
border-radius: 8px;
}
.modalPrice {
font-size: 24px;
line-height: 28px;
margin: 0px;
font-family: 'Barlow', sans-serif;
}
.modal-dialog {
height: 100% !important;
}
.modal-header {
border-bottom: 0px !important;
}
.modal-content {
border: 0px !important;
height: auto;
min-height: 80%;
border-radius: 12px;
}
.modal-body {
/*THIS IS WHERE THE SCROLL is, when I added this ofc it ads a vertical scroll but at the same time the annoying right-margin.*/
height: 200px;
margin-right: 0px !important;
overflow: scroll;
}
.modal-footer {
border-top: 0px !important;
}
<!-- Modal -->
<div class="modal fade" id="viewMenuModal<?= $menu_id ?>" tabindex="-1" role="dialog" aria-labelledby="viewOrderModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="view-menu-modal"> <!--THIS IS WHERE THE OVERFLOW-Y: auto is applied -->
<div class="modalMenu mb-2">
<img class="modalMenu-img" src="images/img/stock/baby-back-ribs.jpeg" alt="blog-img">
</div>
<div class="content-right">
<h3><?= $menu_name ?></h3>
<p class="food-description"><?= $menu_desc ?></p>
<p class="modalPrice">₱ <?= $menu_price ?> </p>
<p>Lorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsumLorem ipsum</p>
</div>
</div>
<div class="modal-footer">
<!-- <button type="button" class="btn btn-lg btn-secondary" data-dismiss="modal">Close</button> -->
<button type="button" class="btn btn-lg primary-btnLink mb-1">Add to Order</button>
<button type="button" class="btn btn-lg secondary-ghostBtn" data-dismiss="modal" aria-label="Cancel">Cancel</button>
</div>
</div>
</div>
</div>

in this your code working fine,if possible use bootstrap css and js
.modalMenu {
float: none;
width: 100%;
height: 200px;
}
.modalMenu-img {
width: 100%;
height:100%;
object-fit:cover;
border-radius: 8px;
}
.modalPrice {
font-size: 24px;
line-height: 28px;
margin: 0px;
font-family: 'Barlow', sans-serif;
}
.modal-dialog {
height: 100% !important;
}
.modal-header {
border-bottom: 0px !important;
}
.modal-content {
border: 0px !important;
height: auto;
min-height: 80%;
border-radius: 12px;
}
.modal-body {
height: 70vh;
overflow-y: auto;
/*THIS IS WHERE THE SCROLL is, when I added this ofc it ads a vertical scroll but at the same time the annoying right-margin.*/
margin-right: 0px !important;
}
.modal-footer {
border-top: 0px !important;
}
#view-menu-modal::-webkit-scrollbar {
/*display:none*/
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#viewMenuModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="viewMenuModal" tabindex="-1" role="dialog" aria-labelledby="viewOrderModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="view-menu-modal"> <!--THIS IS WHERE THE OVERFLOW-Y: auto is applied -->
<div class="modalMenu mb-2">
<img class="modalMenu-img" src="https://image.freepik.com/free-psd/fast-food-concept-banner-template_23-2148777964.jpg" alt="blog-img">
</div>
<div class="content-right">
<h3><?= $menu_name ?></h3>
<p class="food-description"><?= $menu_desc ?></p>
<p class="modalPrice">₱ <?= $menu_price ?> </p>
</div>
</div>
<div class="modal-footer">
<!-- <button type="button" class="btn btn-lg btn-secondary" data-dismiss="modal">Close</button> -->
<button type="button" class="btn btn-lg primary-btnLink mb-1">Add to Order</button>
<button type="button" class="btn btn-lg secondary-ghostBtn" data-dismiss="modal" aria-label="Cancel">Cancel</button>
</div>
</div>
</div>
</div>

Related

How do I make an image take up 100% of a Bootstrap modal container?

I have some bootstrap modals with images in them. Some of them are long vertically which makes a scrollbar appear. I tried to fix this by setting a max-height to the modal-content and having modal-body, where the image is inside of to be 100% of that. Now the backdrop is the height I set it to, but the image still extends past the container.
jsfiddle: https://jsfiddle.net/cLn52tqg/
.modal-content {
max-height: 85vh;
}
.modal-content>.modal-body {
max-height: 100%;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="modal fade show" id="modalImage2" tabindex="-1" aria-labelledby="allImage2" aria-hidden="true" style="display: block;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header text-center">
<h2 class="modal-title w-100 text-dark" id="allImage2">image title</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img class="img-fluid" src="https://images.unsplash.com/photo-1564754943164-e83c08469116?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8dmVydGljYWx8ZW58MHx8MHx8&w=1000&q=80" alt="">
<p class="modalText text-dark text-center mt-2">image description</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Seems like setting a max height is preventing the image to scale down inside the container. Setting height fixed the issue you can add a calc() function if you want to add some extra height into consideration.
.modal-content>.modal-body{
height: 70vh;
overflow: auto;
position: relative;
}
.modal-content>.modal-body > img{
object-fit: contain;
width: 100%;
height: 100%;
}
I setup a custom class for the modal content which will use display: grid for this -- it doesn't work in the tiny little snippet preview but if you run the snippet and view full page you will see it working nicely
.modal-content.grid-content {
display: grid;
grid-template-rows: auto 1fr auto;
height: calc( 100vh - 1.75rem - 1.75rem ); /* Account for vertical margin on parent */
}
.modal-content.grid-content .modal-body {
min-height: 0;
display: grid;
grid-template-rows: 1fr auto;
}
.modal-content.grid-content .modal-body > * {
min-height: 0;
}
.modal-content.grid-content .modal-body img {
display: block;
margin: auto;
max-height: 100%;
/* REMOVE THESE 2 LINES IF YOU WANT IMAGE TO CCENTER INSTEAD OF CROP */
object-fit: cover;
width: 100%;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="modal fade show" id="modalImage2" tabindex="-1" aria-labelledby="allImage2" aria-hidden="true" style="display: block;">
<div class="modal-dialog modal-lg">
<div class="modal-content grid-content">
<div class="modal-header text-center">
<h2 class="modal-title w-100 text-dark" id="allImage2">image title</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img class="img-fluid" src="https://images.unsplash.com/photo-1564754943164-e83c08469116?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8dmVydGljYWx8ZW58MHx8MHx8&w=1000&q=80" alt="">
<p class="modalText text-dark text-center mt-2">image description</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

Bootstrap: how to vertically align two buttons, at the start and the end of a title?

I'm using bootstrap 3 modals, the design I've been asked to do is
Notice how the graphic designer placed a button vertically aligned with the start of the text and another vertically aligned with the end of the text.
My code is
<div class="fr-popup-title">
<div class="modal-title">
<div class="row fr-title-popup-margin">
<?php echo $question_title; ?>
</div>
<div class="row">
<?php echo $you_know; ?>
</div>
<div class="row">
<?php echo $migrant; ?>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-4 pl col-md-push-2">
<button type="button" class="btn btn-warning modal-fr-btn yes-fr-popup" data-dismiss="modal">
<?php echo $yes; ?>
</button>
</div>
<div class="col-xs-4 btn-col pr col-md-push-3">
<button type="button" class="btn btn-warning modal-fr-btn close-fr-popup" data-dismiss="modal">
<?php echo $no; ?>
</button>
</div>
</div>
I get what I want but not the alignment I want, if I add some margins, it will break on another screen, what's the best way to solve it?
Please note that I tried inserting all my code as a snippet and it made more mess than the real deal, don't use the snippet as a reference, my code in a browser is way better, and don't worry about my classes, they seem like a lot but all of them are useless, they are nothing but a failed attempt at aligning.
The one without snippet is the same but easier to read.
$(window).on('load', function () {
$('#francepopup').modal('show');
});
.fr-title-popup-margin {
margin-top: 20px;
}
.fr-popup-title {
font-size: 24px;
font-family: 'Montserrat', sans-serif;
color: #008cc0;
font-weight: 800;
text-align: center;
}
.modal-fr-btn {
border-radius: 40px;
height: 25px;
width: 80px;
font-size: 14px;
font-family: 'Montserrat', sans-serif;
color: white;
font-weight: 800;
}
.dont {
font-family: 'Montserrat', sans-serif;
font-weight: 400;
font-size: 6px;
}
.fr-flags {
margin: 0 auto;
}
.fr-text {
margin: 0 auto 0 3px
}
#media (min-width: 992px) {
.modal-dialog {
width: 30%;
}
}
#media (max-width: 991px) {
.pr {
float: right;
}
.pl {
float: left;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<body>
<div class="modal fade" id="francepopup" role="dialog">
<div class="modal-dialog modal-md">
<!-- Modal content-->
<div class="modal-content">
<button type="button" class="close close-fr-popup" data-dismiss="modal">×</button>
<div class="fr-popup-title">
<div class="modal-title">
<div class="row fr-title-popup-margin">
Are you or is someone
</div>
<div class="row">
you know
</div>
<div class="row">
a migrant in France?
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-4 pl col-md-push-2">
<button type="button" class="btn btn-warning modal-fr-btn yes-fr-popup" data-dismiss="modal">
Yes
</button>
</div>
<div class="col-xs-4 btn-col pr col-md-push-3">
<button type="button" class="btn btn-warning modal-fr-btn close-fr-popup" data-dismiss="modal">
No
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
i simply edited your code and i hope it is what you really needed :)
$(window).on('load', function () {
$('#francepopup').modal('show');
});
.fr-title-popup-margin {
margin-top: 20px;
}
.fr-popup-title {
font-size: 23px;
font-family: 'Montserrat', sans-serif;
color: #008cc0;
font-weight: 800;
/*text-align: center;*/
}
.modal-fr-btn {
border-radius: 40px !important;
/*height: 25px;*/
width: 80px;
font-size: 14px;
font-family: 'Montserrat', sans-serif;
color: white;
font-weight: 800;
}
.dont {
font-family: 'Montserrat', sans-serif;
font-weight: 400;
font-size: 6px;
}
.fr-flags {
margin: 0 auto;
}
.fr-text {
margin: 0 auto 0 3px
}
#media (min-width: 992px) {
.modal-dialog {
width: 30%;
}
}
#media (max-width: 991px) {
.pr {
float: right;
}
.pl {
float: left;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<body>
<div class="modal fade" id="francepopup" role="dialog">
<div class="modal-dialog modal-md">
<!-- Modal content-->
<div class="modal-content">
<button type="button" class="close close-fr-popup" data-dismiss="modal">×</button>
<div class="fr-popup-title">
<div class="modal-title">
<div style="display:flex">
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
<div style="max-width:49.33333333%; text-align:center">
Are you or is someone <br/>
you know <br/>
a migrant in france?
</div>
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
</div>
</div>
</div>
<div class="modal-body">
<div style="display:flex">
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
<div style="max-width:49.33333333%; flex: 0 0 49.33333333%">
<button type="button" style="float:left; width:115px; height:40px; font-size:18px" class="btn btn-warning modal-fr-btn yes-fr-popup" data-dismiss="modal">
Yes
</button>
<button type="button" style="float:right;width:115px; height:40px; font-size:18px" class="btn btn-warning modal-fr-btn close-fr-popup" data-dismiss="modal">
No
</button>
</div>
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
</div>
<br/>
<div style="display:flex">
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
<div style="max-width:49.33333333%; flex: 0 0 49.33333333%; text-align:right; margin-top:-15px">
(Please dont ask <br/> me this again)
</div>
<div style="max-width:25.33333333%; flex: 0 0 25.33333333%;"></div>
</div>
</div>
</div>
</div>
</div>
</body>

Loading div in front of bootstrap modal

I'm using bootstrap and modals for partial views, I have a "loading" div to put in front of everything while getting the data. I can't put the loading div in front of the modal, already tried with z-index but still nothing.
This is my css:
.load {
position: absolute;
z-index: 500 !important;
height: 100%;
display: none;
border: 0;
padding: .5em 1em;
overflow: auto;
top: 0%;
left: 0%;
background: white;
width: 100%;
border: none;
opacity: 0.8;
}
.imagen_loading {
position: absolute;
z-index: 500 !important;
top: 35%;
left: 43%;
width: 300px;
height: 300px;
background: url('../../Content/img/gif/loader3.gif')
}
And this is my modal:
<div class="modal fade" id="modal_aprobar_transferencia" data-target="#modal_aprobar_transferencia">
<div class="modal-dialog">
<div class="modal-content" style="overflow:auto; width:90% !important; height:90% !important;">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Transfers</h4>
</div>
<div class="modal-body">
#{
Html.RenderAction("lista_transferencias", "Almacen");
}
</div>
</div>
</div>
</div>
Edit:
<div class="container-fluid" style="padding-left:7em; padding-right:3em;">
<h3>Storehouse</h3>
<div class="row barra_menu" style=" ">
<div class="" style="float:left;">
<button type="button" class="btn btn-lg btn-info" href="#modal_formulario_altas" data-toggle="modal">
Receives
</button>
</div>
<div class="dropdown">
<button type="button" class="btn btn-lg btn-info dropdown-toggle" data-toggle="dropdown" style="float:left;">
Transfers <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
New transfer
New seal package
See transfers
Receive transfers
</li>
</ul>
</div>
<div class="modal fade" id="modal_nuevos_sellos" data-target="#modal_nuevos_sellos">
<div class="modal-dialog" style="width:30% !important; height:15% !important;">
<div class="modal-content">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Add seal package</h4>
</div>
<div class="modal-body">
<div class="form-group">
<div class="form-group col-3">
<label for="caja_inicio">First seal </label>
<input type="text" class="form-control numeric must " onkeydown="upperCaseF(this)" id="caja_inicio">
</div>
<div class="form-group col-3">
<label for="caja_final">Last seal</label>
<input type="text" class="form-control numeric must " onkeydown="upperCaseF(this)" id="caja_final">
</div>
<div class="form-group col-3">
<label for="caja_sucursal">Branch office </label>
<select type="text" class="form-control" id="caja_sucursal">
<option>Select</option>
<option value="1">Fortune</option>
<option value="2">Lucky one</option>
</select>
</div>
<div class="form-group col-3">
<br />
<button type="button" class="btn btn-primary mb-2" id="boton_guardar_sello" onclick="guardar_sellos_index(event);">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal_aprobar_transferencia" data-target="#modal_aprobar_transferencia">
<div class="modal-dialog">
<div class="modal-content" style="overflow:auto; width:90% !important; height:90% !important;">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Approval of transfers</h4>
</div>
<div class="modal-body">
#{
Html.RenderAction("lista_transferencias", "Almacen");
}
</div>
</div>
</div>
</div>
<!----LISTADO DE INVENTARIO----->
<div class="panel panel-default panel-primary">
<div class="panel-heading"><h4>Inventory</h4></div>
<div style="padding:1em; overflow:auto; ">
<table id="tabla_inventario" class="table table-striped ">
<thead>
<tr>
<th>#Html.DisplayNameFor(model => model.id_inventario)</th>
<th>#Html.DisplayNameFor(model => model.sucursal)</th>
<th>#Html.DisplayNameFor(model => model.po)</th>
<th>#Html.DisplayNameFor(model => model.mill_po)</th>
<th>#Html.DisplayNameFor(model => model.total)</th>
<th>#Html.DisplayNameFor(model => model.categoria_inventario)</th>
<th>#Html.DisplayNameFor(model => model.descripcion)</th>
<th>#Html.DisplayNameFor(model => model.estado)</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>#Html.DisplayFor(modelItem => item.id_inventario)</td>
<td>#Html.DisplayFor(modelItem => item.sucursal)</td>
<td>#Html.DisplayFor(modelItem => item.po)</td>
<td>#Html.DisplayFor(modelItem => item.mill_po)</td>
<td>#Html.DisplayFor(modelItem => item.total)</td>
<td>#Html.DisplayFor(modelItem => item.categoria_inventario)</td>
<td>#Html.DisplayFor(modelItem => item.descripcion)</td>
<td>#Html.DisplayFor(modelItem => item.estado)</td>
<td>
<button type="button" onclick="ver_item(#item.id_inventario)" class="btn btn-default glyphicon glyphicon-search " style="color:black; padding:0px 5px 0px 5px;"></button>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div id="loading" class="load">
<div id="spinner" class="imagen_loading" style=""></div>
</div>
My partial views are mostly the same, tables and edits.
I'd appreciate any help.
The trick in here is data-backdrop="false" style="background-color: rgba(0, 0, 0, 0.5);" by removing the default backdrop and create a dummy one by setting background color of the dialog itself with some alpha.
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="false" style="background-color: rgba(0, 0, 0, 0.5);">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</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>
Notes: clicking on the background does not close the dialogue as is expected.
Solution: So to achieve that you have to add some javascript code. Here is some example of how you can accomplish this.
$('.modal').click(function(event){
$(event.target).modal('hide');
});
HTML: place this within your body tag
<div id="LoaderWindow">
<div id="Loader"></div>
</div>
/* CSS for loading*/
.loader-window {
width: 100%;
height: 100%;
position: fixed;
z-index: 1051;
background: rgba(54, 70, 93, 0.95);
}
.loader {
position: absolute;
top:50%;
left:50%;
border: 8px solid #f3f3f3;
border-radius: 50%;
border-top: 8px solid #5BFEC8;
width: 60px;
height: 60px;
margin-top:-30px;
margin-left:-30px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
You have to use jquery to add class.
function loader(
operation
) {
if (operation == 'add') {
$('#LoaderWindow').addClass('loader-window');
$('#Loader').addClass('loader');
} else {
$('#LoaderWindow').removeClass('loader-window');
$('#Loader').removeClass('loader');
}
}
loader('add') would be used when you request data and after received a response use loader('remove');
When inspecting the modals within the Bootstrap (3 and 4) documentation, it looks like their default z-index is 1050. Did you try increasing the z-index of your loading div to something greater than 1050?
Try setting this styles to your loading div:
#loading {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 9999;
background: url(img/preloader.gif) center no-repeat #fff;
}
Be advised, the loading <div> must be out of the modal <div>.
HTML
<div id="loading"></div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div>

How to scale a background image in a modal?

I have a modal, and I have a background image in it. The only thing I need to do is scale it down. However, when I change the "width", it actually changes the modal's width. I can't come up with a solution. I have read many other posts here on Stackoverflow as well as other sites (such as css tricks) but I can not find a solution. Any thoughts will be more than welcome.
/* Login Modal */
.login-modal-content {
background-image: url('https://cdn.reebit.cl/images/isotipo.png');
background-repeat: no-repeat;
width: 100%;
height: auto;
background-position: right 20px bottom 10px;
}
.login-modal-header {
border-bottom: 0px;
}
.login-modal-body {
width: 100%;
margin: 0 auto;
}
.login-modal-body img {
width: 60%;
}
// My html seems correct to me //
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="modal fade bd-example-modal-lg login-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="loginModal">
<div class="modal-dialog modal-lg">
<div class="modal-content login-modal-content">
<div class="modal-header login-modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body modal-body-img login-modal-body text-center col-lg-6 pb-5 pt-0">
<img src="https://cdn.reebit.cl/images/header-logo.svg">
<h5>¡Hola! Ingresa a tu cuenta</h5>
<form class="login-form">
<div class="form-group login-modal-form-email">
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Correo electrónico">
</div>
<div class="form-group login-modal-form-password">
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Clave">
</div>
<button type="submit" class="btn btn-block btn-modal-login">Ingresar</button>
</form>
Olvidé mi clave
</div>
</div>
</div>
</div>
You probably wanna try using background-size CSS property:
/* Login Modal */
.login-modal-content {
background-size: cotain; // Or 'cover'
background-image: url('https://cdn.reebit.cl/images/isotipo.png');
background-repeat: no-repeat;
width: 100%;
height: auto;
background-position: right 20px bottom 10px;
}
There's a very good tutorial here too: https://css-tricks.com/almanac/properties/b/background-size/

Horizontal scroll bar bot working in bootstrap modal

I am having a modal, showing div in 'modal-body'.
<div class="modal-body">
<div class="scoll-tree">
<div class="history">
Report Event Details
</div>
<div class="history">
Report Event Details 1
</div>
<div class="history">
Report Event Details 2
</div>
<div class="history">
Report Event Details 3
</div>
</div>
</div>
Set the class as bellow :
.scoll-tree{
width: 400px;
height:80px;
overflow-x: scroll;
}
.history {
background: rgba(255, 255, 255, 0.7);
float: left;
min-width: 5em;
width: 25ex;
max-height: 3em;
margin: 2em;
padding: 1em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 16px;
box-shadow: 2px 5px 5px rgba(0,0,0,0.2);
vertical-align: central;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
I want horizontal scroll bar to 'scoll-tree' container, when 'history' div exceed the width.
Currently it give vertical scroll bar, i want only horizontal scroll bar.
https://jsfiddle.net/hemantmalpote/4duq2svh/35/
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Modal Example</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<div style="height:100px; width:100px; overflow-x:auto">
Content1
Content2
Content3
Content4
Content5
Content6
Content7
Content8
Content9
Content10
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Well not sure whether it is what you are looking for, but check it https://jsfiddle.net/4duq2svh/44/. I changed you css little bit,
.modal-body {
width: 400px;
overflow-x: scroll;
}
.scoll-tree{
width: 800px;//ideally you it is better to make js script which will calculate this value
height:80px;
}
Very Simple -
Just use max-width instead of width & set overflow-x: auto.
So it will be -
.scoll-tree{
max-width: 400px;
height:80px;
overflow-x: auto;
}
You may first set it to 200px for testing whether scroll appears or not.