Could someone please help me understand this situation? I have posted my code on jsfiddle. I am using Bootstrap 4. In my design, I have text placed over an image with the parent div having position:relative
. The left div has position:absolute
and left:2%
, while the right div has position:absolute
and right:2%
. This setup works fine on larger screens, but it breaks on smaller or mobile screens, so I want to move it to a new column. You can see this behavior in the jsfiddle by resizing the screen.
I have tried using Bootstrap classes like
<div class="col-lg-6 col-md-6 col-sm-12">
.
<div class="col-md-12 col-sm-12 col-xs-12 nopadding" style="margin-bottom: 15px; position: relative;">
<img src="assets/img/klupa_fontana.jpg" class="img-fluid">
<div style="position: absolute; top: 10%; left: 50%; transform: translate(-50%, -50%);">
<span style="color: #fff; font-size: 60px; line-height: 1.07143; font-weight:400;"> Lorem ipsum dolor</span><br><br>
</div>
<div class="col-md-6 col-sm-12 col-xs-12">
<div style="position: absolute; top: 15%; left: 2%;">
<span style="color: #fff; font-size: 50px; line-height: 1.07143; font-weight: 300;"> Lorem ipsum dolor.</span><br><br>
<span style="color: #fff; font-size: 40px; line-height: 1.07143; font-weight: 300;"> Lorem ipsum dolor Lorem ipsum dolor<br> Lorem ipsum dolor Lorem ipsum dolor.</span>
</div>
</div>
<div class="col-md-6 col-sm-12 col-xs-12">
<div style="position: absolute; top: 15%; right: 2%; text-align: right">
<span style="color: #fff; font-size: 50px; line-height: 1.07143; font-weight: 300;"> Lorem ipsum dolor Lorem ipsum dolor <br> fast and safe.</span><br><br>
<span style="color: #fff; font-size: 40px; line-height: 1.07143; font-weight: 300;"> Lorem ipsum dolor Lorem ipsum dolor<br> Lorem ipsum dolor Lorem ipsum dolor<br> Lorem ipsum dolor Lorem ipsum dolor</span>
</div>
</div>
</div>
Thank you