Reputation: 85
I have a div where there is an image inside that div. However I have a problem, that it is not respecting the size of the div, and it is overlapping it.
.bs-col-md-6 {
box-sizing: border-box;
-ms-flex-positive: 0;
flex-grow: 0;
0;
*/ -ms-flex-negative: 0;
flex-shrink: 0;
padding-left: 15px;
padding-right: 15px;
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%;
}
.bsp-login-banner {
position: fixed;
top: 0;
left: 0;
width: 50%;
height: 100%;
object-fit: cover;
z-index: 1;
}
<div class="bsp-xs-hidden bsp-sm-hidden bs-col-md-6">
<img class="bsp-login-banner" src="assets/img/Login.jpg" alt="the image is here" />
</div>
Can someone help me?
Upvotes: 0
Views: 1614
Reputation: 13
.bs-col-md-6 {
box-sizing: border-box;
-ms-flex-positive: 0;
flex-grow: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
padding-left: 15px;
padding-right: 15px;
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%;
}
.bsp-login-banner {
width: 50%;
height: 100%;
object-position: center;
object-fit: cover;
z-index: 1;
}
<div class="bsp-xs-hidden bsp-sm-hidden bs-col-md-6">
<img class="bsp-login-banner" src="assets/img/Login.jpg" alt=""/>
</div>
Upvotes: 0
Reputation: 11
You need to give the div some respectful size to handle this according to the image.
The concern with fixed positioning is that it can cause situations where the fixed element overlaps content such that it is inaccessible. The trick is having enough space to avoid that or using relative or absolute positioning instead.
Upvotes: 0
Reputation: 67778
Don't use position: fixed
- this will completely take that element out of the context of all other elements (except the window/viewport).
It's not completely clear what you want, but you can use position:absolute
instead and apply position: relative
to its parent to make that the reference element for its position (and to some extent for its size, if defined).
Upvotes: 1