I'm encountering an issue with my HTML/CSS structure:
.im-wrapper {
width: 100%;
height: 100%;
position: fixed;
overflow: hidden auto;
top: 0;
left: 0;
}
.im-backdrop {
background-color: var(--darkblack);
opacity: 80%;
width: 100%;
height: 100%;
overflow: hidden;
position: fixed;
outline: 0;
}
.im-container {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
padding: 0 8px;
box-sizing: border-box;
text-align: center;
}
.im-container:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.im-wrapper .im-content {
opacity: 100%;
box-shadow: 0 0 8px rgb(0 0 0 / 80%);
min-width: 50%;
margin-right: 40px;
margin-left: 40px;
}
.im-image-holder .im-content {
max-width: 100%;
}
.im-content {
position: relative;
display: inline-block;
vertical-align: middle;
margin: 0 auto;
text-align: left;
max-width: 100%;
}
.im-figure {
background: var(--black);
line-height: 0;
cursor: pointer;
}
.im-close {
color: white;
cursor: pointer;
padding-right: 45px;
right: 0;
top: 0;
height: 45px;
width: 45px;
line-height: 45px;
position: absolute;
text-decoration: none;
opacity: 65%;
font-size: 28px;
font-weight: bold;
}
button.im-close {
overflow: visible;
background: 0 0;
border: 0;
display: block;
outline: 0;
padding: 0;
box-shadow: none;
}
.im-wrapper .im-content .im-figure .im-img {
padding: 0;
}
img.im-img {
width: auto;
max-width: 80%;
height: auto;
display: block;
line-height: 0;
box-sizing: border-box;
padding: 40px 0;
margin: 0 auto;
}
.im-bottom-bar {
max-height: 20%;
background-color: var(--cyan);
top: 100%;
left: 0;
width: 100%;
cursor: auto;
padding: 0 15px;
}
.im-title {
text-align: left;
line-height: 18px;
word-wrap: break-word;
color: var(--black);
}
.im-collapsed {
padding: 0 15px;
}
.im-left-bar {
font-size: 0.8em;
}
.im-bottom-bar h2 {
border-bottom: 1px solid var(--black);
font-size: 1rem;
padding-bottom: 2px;
}
.im-bottom-bar .im-left-bar.im-collapsed .row>div {
border-right: 1px solid var(--black);
}
.im-bottom-bar .im-left-bar.im-collapsed .row>div:last-of-type {
border-right: none;
}
.im-bottom-bar .im-left-bar {
padding: 10px;
}
.im-counter {
position: absolute;
top: 0;
right: 0;
color: #ccc;
font-size: 12px;
line-height: 18px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cba9a4a4bfb8bfb9aabb8bfee5f9e5f8">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<div class="im-wrapper">
<div class="im-container im-image-holder"><div class="im-content">
<div class="im-figure">
<button title="Close" type="button" class="im-close">×</button>
<figure>
<img class="im-img" src="https://media.istockphoto.com/id/185235465/photo/white-toast.jpg?s=1024x1024&w=is&k=20&c=3UrLtuMZhHW6AfLbpM-87W0pW2oQHKe7End6hfgG0g0=" style="max-height:1010px">
</figure>
<figcaption>
<div class="im-bottom-bar">
<div class="im-title">
<div class="row">
<div class="col-12 im-collapsed im-left-bar">
<div class="row">
<div class="col-lg-6 text-left">
<h2>Credits</h2>
<div class="mb-1">stuff by waa</div>
</div>
<div class="col-lg-6 text-left">
<h2>Characters</h2>
<div class="mb-1">:3</div>
</div>
</div>
</div>
</div>
</div>
<div class="im-counter"></div>
</div>
</figcaption>
</div>
</div>
</div>
</div>
I'm puzzled by the behavior I'm observing. When I rearrange the code by moving the
<div class="im-content">
out of line with <div class="im-container im-image-holder">
, the image no longer resizes properly and shifts position. This change seems minor, but it has a significant impact on the layout. Any insights on why this happens?