Trying to work on making the header portion of my website (starting with the mobile class). When I am trying to create a col-xs-7 which contains one h1 and two p tags, and a col-xs-5 which contains an image. The col-xs-7 completely takes over the entire row and throws the col-xs-5 column into a new row. Spent some time reading documentation and similar questions, but still got the same results. Below is a diagram of the results I’m getting and a code snippet. Cheers!
<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<!-- Body -->
<div class="container">
<div class="row">
<div class="col-xs-7">
<h1 class="text-justify">Name</h1>
<p class="text-justify">Company</p>
<p class="text-justify">Role</p>
</div>
<div class="col-xs-5">
<img class="img-fluid w-25 float-end" src="https://via.placeholder.com/200.png">
</div>
</div>
</div>
2
Answers
The issue is caused by the class
float-end
class on the image which moves the element out of flow and floats it. Also note, that Bootstrap 5+ has noxs
breakpoint as it is the default breakpoint.I think using flexBox will give you more control
Documentation on flex and the wrap properties
(I’m not familiar with bootstrap so my example will need some tweaking. This would be my approach using vanilla css.)