Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bootstrap – row cols aren't aligning – image is going into a completely new row

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!

Example

<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/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>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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 no xs breakpoint as it is the default breakpoint.

<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">


<!-- Body -->
<div class="container">
    <div class="row">
        <div class="col-7">
            <h1 class="text-justify">Name</h1>
            <p class="text-justify">Company</p>
            <p class="text-justify">Role</p>
        </div>
        <div class="col-5">
            <img class="img-fluid w-100" src="https://via.placeholder.com/200.png">
        </div>
    </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading