I build a page with a parallax effect and an image gallery using Bootstrap 4. The problem is that the background image jumps/resizes when I open a modal and I feel like I tried everything to fix this. BS does a good job keeping all other elements where they are, scrollbar or not, but not the background image.
<
// call ekko-lightbox
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
event.preventDefault();
$(this).ekkoLightbox();
});
body {
position: relative;
font-size: 100%;
}
body,
html,
h1,
h2,
h3,
h4,
h5,
h6,
p {
font-family: "Lato", sans-serif;
line-height: 1.8;
}
body,
html {
height: 100%;
color: #666666;
}
.bgimg-1 {
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
background-color: black;
background-image: url("https://cdnb.artstation.com/p/assets/images/images/005/540/665/large/thorsten-erdt-nami-small.jpg?1491824822");
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.css">
<body>
<header class="container-fluid h-100 bgimg-1" id="home">
<div class="row h-100 justify-content-center align-items-center">
<div class="col col-sm-auto text-white text-center">
<h2 class="d-md-none">ART OF</h2>
<h2 class="bg-dark d-block">THORSTEN ERDT</h2>
<h2 class="d-none d-md-block">ILLUSTRATION</h2>
</div>
</div>
</header>
<section class="container" id="editorial">
<div class="row justify-content-center">
<a href="IMG" data-toggle="lightbox" data-gallery="img-gallery"><img src="thumbnail" alt="captiontext1" style="width:50px"></a>
</div>
</section>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.js"></script>
If I set
background-size:{auto;}
background-position: {left top;}
it wont jump anymore, but it wont resize for smaller devices either, so that wont do.
If I set
overflow-y:{scroll;}
it still adds padding to everything which results in everything jumping...
body.modal-open {padding:0;}
fixes that, but now the navbar is the only thing jumping. Oh and of course I can scroll the page while the modal is open, too.
If someone has another idea how to fix this I am all ears.