Tips on aligning images of various sizes with text within a row using CSS

Looking for help aligning four different height (ranging from 160-180px) svg images with text positioned directly below each image. I want the images to be neatly aligned in a row, but I'm struggling to align the short text underneath them in a single line as shown in the screenshot.

Thank you in advance!

https://i.stack.imgur.com/RdRbY.png

Update: Apologies for any confusion, I assumed this was a common issue for those experienced in CSS. Here is my HTML and CSS code, along with my use of bootstrap rows.

    <div class="did-you-know">
    <div class="row items">
        <div class="col-lg-3 col-xs-6">
            <div class="icon">
                <img src="/img/mswa/inline-wa.svg"/>
            </div>
            <div class="title text-poppins">
                <p>We’re from WA</p>
                <p>{like you!}</p>
            </div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <div class="icon">
                <img src="/img/mswa/inline-packaging.svg"/>
            </div>
            <div class="title text-poppins">
                <p>We use minimal packaging</p>
                <p>{great for the planet}</p></div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <div class="icon">
                <img src="/img/mswa/inline-quality.svg"/>
            </div>
            <div class="title text-poppins">
                <p>We only choose quality</p>
                <p>{better for your health}</p></div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <div class="icon">
                <img src="/img/mswa/inline-community.svg"/>
            </div>
            <div class="title text-poppins">
                <p>We love giving back</p>
                <p>{great for our community}</p></div>
        </div>
    </div>
</div>


.did-you-know {
    padding: 20px;
    text-align: center;
}

.did-you-know .items .icon {
    padding: 50px;
}
.did-you-know .items .title {
    font-size: 20px;
}

Answer №1

Here is a solution:
Please replace the images with your own images.

<!DOCTYPE html>
<html>
<head>
<style>
* {
  box-sizing: border-box;
}

.column {
  float: left;
  width: 25%;
  padding: 5px;
}

/* Clearfix (clear floats) */
.row::after {
  content: "";
  clear: both;
  display: table;
}
</style>
</head>
<body>

<div class="row">
  <div class="column">
    <img src="https://freesvg.org/img/cartoonsun.png" alt="Sun" style="width:100%">
    <p style='text-align: center;'>test1</p>
  </div>
  <div class="column">
    <img src="https://freesvg.org/img/cartoonsun.png" alt="Tree" style="width:100%">
        <p style='text-align: center;'>test2</p>

  </div>
  <div class="column">
    <img src="https://freesvg.org/img/cartoonsun.png" alt="River" style="width:100%">
    <p style='text-align: center;'>test3</p>
  </div>
  <div class="column">
    <img src="https://freesvg.org/img/cartoonsun.png" alt="Beach" style="width:100%">
    <p style='text-align: center;'>test4</p>
  </div>
  
</div>

</body>
</html>

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

Step-by-step guide on using variables to apply CSS

In our table consisting of 6 rows and 2 columns, the second column displays a Font Awesome circle followed by various values in the database field (such as Outstanding, Very Good, Good, Needs Improvement, and Adequate). I am looking to dynamically change ...

CSS: Struggling with Div Alignment

Here is a visual representation of the issue I am facing: View the screenshot of the rendered page here: http://cl.ly/image/0E2N1W1m420V/Image%202012-07-22%20at%203.25.44%20PM.png The first problem I have encountered is the excessive empty space between ...

CSS: Using absolute and relative positioning within a parent element can result in elements overlapping

I want to create a box in html/css where the read more hyperlink text is positioned over the background image. The goal is to have additional text added to the description without overlapping the image. Here's an example of the current issue. Curren ...

jQuery function failing to produce the intended results

I am trying to apply the active class to the last img element using HTML and jQuery Below is my code in HTML and jQuery: function initialSteps() { $(".row").find("column:last").find("img:first").className += " active"; // this does not work either ...

Verifying the status of a checkbox label in Java using Selenium

I am currently working on an automation project using Selenium and I'm struggling to figure out how to check the status of a checkbox input. Has anyone else encountered this issue before? Here is a sample code snippet in JavaScript with jQuery: $("i ...

The Django server fails to display the CSS files upon activation

Despite having all the static files in place, only the plain HTML loads without any styles for some unknown reason. I've attempted using collectstatic and even setting up a new project, but to no avail. STATIC_URL is also properly specified along with ...

Element on navigation bar extending full width of the page

As a fairly new designer, I am facing an issue with my navbar button. Currently, it is only 100 pixels wide and fixed in place, allowing the rest of the page to scroll past it. However, although it is confined to 100PX in width, it still spans across the e ...

Reposition the span element to the right of the div tag

I need help adjusting the positioning of the elements in this HTML code. How can I move the span element with the image to the right of the div tag? Here is the code snippet: <div style='width:600px;padding-top: 2px;padding-bottom: 1px'& ...

keep the color of the link after clicking until a different link is clicked

At the bottom of every post on my website, there are 3 buttons: "Written By", "Related Post," and "In This Category": SoCatchy! I'm looking to have each button change color when clicked, and stay that way until another link is clicked. Here is the c ...

Is it normal that my website isn't scrollable on an iPhone?

I have a hunch that the issue is related to the CSS, or perhaps it could be due to including the parallax JavaScript library. You can view the site at Below is the SASS code snippet: @import "compass/css3"; /* Sticky footer styles ---------------------- ...

Do you require assistance with creating an image slideshow?

My first day working with HTML was a success as I successfully built a navigation bar that looks pretty cool. Take a look at it here. Next on my list is to incorporate a slideshow into my site, possibly using JavaScript or jQuery plugins. I'm aiming ...

Increase transparency of scrollbar background

Is it possible to adjust the opacity of a scrollbar track? I attempted to use opacity:0.5, but it didn't have any effect. I am using material UI styled, although I don't believe that is causing the issue. const Root = styled('div')(({ ...

Center and align pictures within a stationary container

I am working on a simple webpage that has a fixed footer. In this footer, I want to have 5 images centered with equal distances between them. Below is my HTML/CSS : Footer div : div.fixed { position: fixed; bottom: 0; right: 0; width: ...

Tips for making the background image fit perfectly within a div element

I have a calendar div that I want to customize with a background image and text. How can I achieve this? Here is my code: .calenderArrivalDiv{ margin-top: 15%; margin-bottom: 1%; background-image: url("im ...

Center the image and align the floated texts on each side horizontally

I've recently started learning about HTML and CSS, but I'm having trouble grasping one concept. My goal is to align two floating <p> elements on either side of a centered <img>. Here's an example of what I'm trying to achiev ...

By utilizing the body element as the container instead of a div, the content shifts to the left by eight pixels

When the body is used as the wrapper instead of a div, the content shifts eight pixels to the left (on a 1920×1080 display) when it extends below the fold. The examples below illustrate this difference in code snippets. Please note that the variance is on ...

Unspecified variable in AngularJS data binding with Onsen UI

I am new to Onsen UI and AngularJS, and I have a simple question about data binding. When I use the variable $scope.name with ng-model in an Onsen UI template, it returns as UNDEFINED. Here is my code: <!doctype html> <html lang="en" ng-app="simp ...

Is the text alignment off?

I've been immersed in creating a website, but I encountered an issue for which I can't seem to find the solution. Check out my text alignment here (test) - it's not aligned all the way to the left of the content Here is the HTML code: < ...

container that fades away, while the popup remains visible

Is it possible to fade the background of a container without affecting the pop-up form inside? I've come across some solutions, but they all seem to treat them separately. Here's what I'm trying to achieve: <div class='wrapper ...

Tips for correctly linking JS and CSS resources in Node.js/Express

I have a JavaScript file and a stylesheet that I am trying to link in order to use a cipher website that I created. Here is my File Path: website/ (contains app.js/html files and package json) website/public/css (contains CSS files) website/public/scri ...