What is the best way to make sure images and text are properly aligned for different screen sizes

I'm a beginner with Bootstrap and could use some assistance.

In my code, I have text and images divided into four columns with alignment set based on screen size using media queries in CSS. However, when resizing the window to tablet view (check Screenshot No. 1), it appears messy as the text is too large and the image is too close. At this tablet view, I'd like the columns to align vertically (like Screenshot No. 2) with the image on the left side, and the text and headings next to the image. This change should not affect the mobile view where everything is centered (Screenshot No. 3).

If my question isn't clear enough, please refer to the template at

They have a "Work Team" section that I would like to replicate.

I appreciate any help!

Thank you!

<div class="jumbotron">
<div id="wrapper"> <!--Wrapper-->
    <div class="container"> <!--Container-->
        <div class="row" style="padding-bottom: 40px;">
            <div class="col-md-12" align="center">
                <h1>Meet Us</h1><hr class="style1"></hr>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-3">
                <img src="images/11.jpg" class="img-circle img-responsive" width="180"/>
            </div>
            <div class="col-sm-3">
                <h2 class="style1">Shaikh Obaidullah</h2>
                <h3 class="style1">CEO / Web Developer</h3>
                <hr class="style2"></hr>
                <p class="style1">I will be taking care of product development stages such as Requirements, Development, Functionality, Usability, and Technical Support.</p>
            </div>
            <div class="col-sm-3">
                <img src="images/12.jpg" class="img-circle img-responsive" width="180"/>
            </div>
            <div class="col-sm-3">
                <h2 class="style1">Ovais M. Shaikh</h2>
                <h3 class="style1">Graphic Designer</h3>
                <hr class="style2"></hr>
                <p class="style1">I will spice up your product with creative and unique designs so that you get the most attracted product in the end.</p>
            </div>
        </div>
    </div> <!--Container-END-->
</div> <!--Wrapper-END-->

    .jumbotron {
    background-image: url('../images/13.jpg');
    background-attachment: fixed;
    padding-top: 0px;
    padding-bottom: 0px;
    margin-bottom: 0px;
}

.img-responsive {
    margin: 0 auto;
}

#wrapper {
    background-color: #FFF;
    background: rgba(0,0,0,.7);
    color: #FFF;
    padding-bottom: 40px;
}


hr.style1 {
    margin-bottom: 30px;
    margin-top: 30px;
    width: 100px;
    border-top: 2px solid #8884bc;
}


@media (min-width: 768px) {
h2.style1{
    color: #8884bc;
    text-align: left;
    margin-bottom: 0px;
}

h3.style1{
    text-align: left;
    margin-top: 10px;
}

hr.style2 {
    margin-bottom: 50px;
    margin-top: 50px;
    margin-left: 0px;
    width: 100px;
    border-top: 2px solid #8884bc;
}

p.style1{
    font-size: 20px;
    text-align: left;
    color: #eee;
}

.jumbotron{
    margin-bottom: 0px;
}
}

@media only screen and (max-width:768px) {
hr.style2 {
    margin-bottom: 30px;
    width: 100px;
    border-top: 2px solid #8884bc;
}

h2.style1{
    color: #8884bc;
    text-align: center;
    margin-bottom: 0px;
}

h3.style1{
    text-align: center;
    margin-top: 5px;
    font-size: 20px;
}

p.style1{
    margin-bottom: 80px;
    font-size: 16px;
    text-align: center;
    color: #eee;
}
}

Answer №1

It seems like there might be a misunderstanding in your code. Here's how I believe it should look:

<div class="row">
  <<div class="col-md-5">    
    <div class="left">
      <img>
    </div>
    <div class="right">
      <h1>
      some text
      </h1>
    </div>
  </div>  

  <<div class="col-md-5">    
    <div class="left">
      <img>
    </div>
    <div class="right">
      <h1>
      some text
      </h1>
    </div>
  </div>   
</div>

Additionally, ensure that the class "right" has float:right; and the class "left" has float:left;. The col-md-5 should have display: inline-block;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Load Angular component on demand with necessary dependencies

Searching for an elegant solution (without resorting to private APIs) to create a widget-style dashboard. The goal is to dynamically load components based on user role. Is there a way to import a component and its dependencies included in the component&ap ...

Click here to view the latest Poll Results!

I have implemented AJAX to display poll results on the same page without requiring a refresh. An issue I am facing is that the poll section occupies about three times more space than the results. This causes an inconvenience for users who vote, as they ma ...

Resizing cell height in an HTML table is not supported by Angular 5

In my angular application, I've implemented a component that represents a basic HTML table. However, I'm facing an issue with reducing the height of cells within the table. It seems like my CSS styling is not affecting the display as desired. He ...

What is the best method for fetching the values of a select element in React.js?

I'm struggling to retrieve the value of a selected element in a dropdown list. I've tried debugging it, but haven't been able to get the value. I attempted to console log e.target.value, but unfortunately, it didn't work. Any thoughts o ...

How to set up a Carousel as the background within a div using Bootstrap 5

I'm attempting to create a visually appealing layout by showcasing a Carousel component behind some text. The idea is to have scrolling and fading images with a prominent header overlaid on top of them. I want the carousel images to be contained withi ...

I aim to have the capability to read numbers entered into text fields within a form prior to the form being submitted

I am currently working on a website where users can create brackets for the World Cup by guessing scores and winning teams. Right now, they have to manually fill in the bracket. I would like to implement a feature that reads what users are inputting while ...

Adjust the sidebar size in Bootstrap 5 to align perfectly with the navbar brand

https://i.stack.imgur.com/Ra0c7.png I'm trying to ensure that the width of the sidebar on this page aligns consistently with the end of the logo in the top right. However, using variations of col-xxl-1 etc. is causing inconsistent sizes at different ...

Tips for concentrating on the initial input field produced by an ng-repeat in AngularJS

Currently, I am dynamically generating input fields using ng-repeat and everything is working smoothly. However, my requirement is to set focus on the first input that is generated by this ng-repeat based on their sequenceId values. So far, I have attempte ...

Exploring the functionality of the SVG tag tref in Microsoft Edge

I experimented with using the svg tag tref according to the W3C SVG specification 1.1 in the following manner: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>< ...

Tips for configuring the navigation links on the current page using Bootstrap

In my Angular application, I have set up navigation links for home, about, notifications, and logout. However, when I click on the home link, it redirects me to the login page instead of remaining on the current page. I need the functionality to stay on ...

Is there a way to create an X shape by rotating two divs when I click on the container div?

I currently have this setup: code Below is the HTML code: <div id="box"> <div id="line1" class="line"></div> <div id="line2" class="line"></div> <div id="line3" class="line"></div> </div> My go ...

Whenever my code is used within Google Sites, it triggers the opening of a new and empty tab

When using this code inside an HTML box in Google Sites, a problem arises. It seems to work perfectly fine in Internet Explorer and Chrome when saved to an HTML file. However, within Google Sites, it unexpectedly opens a new tab with no data. The code st ...

Clicking on the icon reveals the current date

I need some help with the input field that displays the calendar date. Currently, I can only click on the input field to show the calendar date. What I actually want is for users to be able to click on a calendar icon to display the calendar date, which sh ...

The viewport width in NextJS does not extend across the entire screen on mobile devices

I'm currently tackling a challenge with my NextJS Website project. It's the first time this issue has arisen for me. Typically, I set the body width to 100% or 100vw and everything works smoothly. However, upon switching to a mobile device, I not ...

How can I make the scrollbar invisible in the sticky header of a Material UI Table?

In my React project, I have implemented a Material-UI Table with a fixed header. The issue I am facing is that the scrollbar in the table header overlaps it and I want to hide it while still displaying it in the body of the table. I have attempted to modi ...

Utilizing HTML/CSS to display text and an image positioned above a sleek navigation bar

I am struggling to align a logo on the left side of my website, with text on the right next to it, all placed above the navigation bar. Despite my efforts, I just can't seem to get them positioned correctly! CSS .headerLogo{ float:left; marg ...

Tips for aligning content produced by *ngFor within a bootstrap grid

I am trying to center content in a row using the Bootstrap grid system. While I have checked out various examples, such as this one, my case is unique because I am utilizing a separate angular component for generating the content. Here is the code snippet ...

Interactive user-friendly form with real-time response features

I am currently working on an application form where users need to answer questions, and I am in need of some responsiveness. Specifically, I would like to implement a feature that shows additional fields based on the user's selection. For example, if ...

The width of Highcharts increases proportionally to the growth of the chart's width

I want to create a highcharts graph where the width increases as data points increase. Currently, I have: I am using vuejs with highcharts, but it should work similarly with jquery or other frameworks. <div class="col-md-6" style= ...

Enhancing WordPress Icons for Parent and Child Elements

I am seeking to customize icons on a WordPress website. The site contains a variety of product categories, including subcategories. https://i.sstatic.net/sTm1O.png My goal is to display one icon for parent categories and a different icon for child catego ...