How to align multiple span elements vertically using HTML and CSS

<div class="row history">
    <div class="col col-50 histroy1">
        <span class="my-orders">Statistics</span>
        <span class="my-orders-numbers">27</span>
     </div>
     <div class="col col-50 histroy2">
        <span class="orders-status">In Transit<span>4</span></span>
        <hr />
        <span class="orders-status">Delivered<span>23</span></span>
     </div>
</div>

.my-orders{
    font-size: 14px;
    display: block;
}
.my-orders-numbers{
    font-size: 37px;
    color: #F04C3A;
    display: block;
}

I am looking to vertically center both the 'Statistics' and '27' spans within the history1 div. How can I achieve this so that both elements align in the middle of the div, with 'Statistics' appearing above '27'? Thank you for your assistance.

UPDATE: Apologies for any confusion in my previous explanation. Here is an image for reference: https://i.stack.imgur.com/zeSxo.png

My goal is to vertically align both 'Numbers' and '13', while also vertically aligning 'In Progress' and 'Completed' texts alongside the horizontal line (


). Any tips on how to accomplish this would be greatly appreciated.

Answer №1

It seems like you are seeking some specific information, although the details provided are limited. Let me try to address your query based on what I understand.

.statistics{
text-align: center;
}
.order-details{
    font-size: 16px;
    display: inline-block;
    vertical-align: middle;
}
.order-numbers{
    font-size: 40px;
    color: #2ECC71;
    display: inline-block;
    vertical-align: middle;
}
<div class="row statistics">
    <div class="col col-50 order-details">
        <span class="order-details">Reviews</span>
        <span class="order-numbers">27</span>
     </div>
     <div class="col col-50 sales-details">
        <span class="sales-stats">Pending<span>5</span></span>
        <hr />
        <span class="sales-stats">Completed<span>22</span></span>
     </div>
</div>

Answer №2

To properly align the elements, make sure to include the following CSS:

display: inline-block;
vertical-align: middle;

For a visual example, check out this link: http://codepen.io/kevinfarrugia/pen/WRGaLP

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

The issue arises when the Javascript function is triggered twice, resulting in only 3 out of 4

I'm currently working on a JavaScript calculator project. Everything is running smoothly except for the add() function (subtraction, multiplication, and division are all functioning properly). Additionally, when I hit "=" it displays the answer twice ...

Having trouble converting HTML to Ajax

When working on my website's Videos Page Layout, I encountered this snippet in the video script: <div class="video-views pull-left"> {$videos[i].viewnumber|kilo} {if $videos[i].viewnumber == '1'}{t c='global.view&apo ...

What is the best way to ensure consistent code placement at the bottom of my Django Template using inheritance?

Lately, I've been working on incorporating a footer into my layout.html file that is inherited by all other pages within my Django project. I am aiming to create a footer that remains fixed at the bottom of every webpage just like how Stack Overflow ...

Wordpress easily adjusts post alignments for a seamless display

Can anyone help me figure out how to properly align posts in Wordpress to match the example image attached? I've tried using inline-block or float with CSS/HTML, but the posts are not aligning correctly. I'm unsure of what this method is called s ...

When navigating back, the Bootstrap Multistep Form breaks down

Tools I'm currently utilizing: HTML, CSS, Javascript, Bootstrap 3 Library / Package in use: https://codepen.io/designify-me/pen/qrJWpG Hello there! I am attempting to customize a Codepen-based Bootstrap Multistep Form from the provided link abov ...

The progress indicator fails to activate during the first step

As a beginner in coding, I wanted to incorporate a progress bar on my website. However, I encountered an issue where when I try to make step 1 "active", it's actually step 2 that becomes active, and the same pattern continues for subsequent steps. ...

Is it possible for iText 5 to convert PDF files into HTML format?

My latest project involved using iText 5 to generate a visually appealing report complete with tables and graphs. Now I'm curious to know if iText also has the capability to convert PDF files into HTML format. If it does, how would one go about doing ...

Error loading custom Javascript in MVC 4 view during the first page load

I'm working on an MVC 4 application that utilizes jQuery Mobile. I have my own .JS file where all the functionality is stored. However, when I navigate to a specific view and check the page source, I notice that all scripts files are loaded except fo ...

Expanding on the specific properties of a parent component to its child, using SASS's extend feature

Can selected or specific properties be shared/extended from the parent to the child without the need to create a variable? .main-container { padding: 20px; margin: 20px; ul { padding:$parentPadding(); margin: 0; } ...

Reorganize containers without relying on bootstrap styling

Is there a method to rearrange the order of two divs without using the bootstrap library? <div class='parent'> <div class='child-1'>Abc..</div> <div class='child-2'>Xyz..</div> </div> I ...

The JS content failed to load into the HTML page

I need help creating a workout tracker using two JS files. The main.js file is responsible for loading content from the second file (workoutTracker.js) into the index.html. However, I'm facing an issue where the content is not being displayed on the p ...

I am looking to pair a unique audio clip with each picture in my collection

I have implemented a random slideshow feature that cycles through numerous images. I am now looking to incorporate a brief audio clip with each image, synchronized with the array I have established for the random pictures. The code snippet below is a simil ...

The execution of the code may encounter errors initially, but it generally runs without any issues on subsequent attempts

I recently developed a piece of code to ascertain whether a value in the database is null or not. Here's the snippet: var table; var active = false; function CheckActive(table){ this.table = "table" + table + ""; var db = window.openDatabas ...

Tips on making Material-UI Drawer compress other content when it is open

Seeking assistance from those familiar with CSS and Material UI! I'm currently working on implementing a Material UI Drawer component that doesn't just slide out over the top of the page content, but actually causes the page content to adjust aro ...

The canvas game's animation can only be activated one time

I am currently working on designing a straightforward canvas game: Here is the code snippet located on CodePen var canvas; var ctx; var x = 300; var y = 400; var r = 0; var mx = 0; var my = 0; var WIDTH = 600; var HEIGHT = 400; function circle(x,y,r) ...

What is the process for executing a Js file on a website?

I am looking to automate some tasks on a website that I do not own. Specifically, I need to automatically fill out a form and perform certain clicking actions. Can JavaScript be used for this purpose? I am unsure how to run a .js file on a site without the ...

Angular 8 is facing an issue where classes defined dynamically in the 'host' property of a directive are not being properly applied to the parent template

In my Angular 8 application, I am working on implementing sorting using the ng-bootstrap table. I referred to the example available at . In the sample, when I hover over the table header, it changes to a hand pointer with a highlighted class applied as sho ...

Comparing the name and URL of a link using Selenium webdriver in C#

I am currently looking for ways to automate the testing of links on a Sharepoint site, ensuring they are connected to the correct URL. However, I have hit a roadblock when it comes to performing the comparison. After locating the links and adding them to ...

How can you combine accessibility with absolute positioning?

Have you seen our unique hamburger design? https://i.stack.imgur.com/AmT6P.png A simple click will reveal a neat popup (the class "open" is added to a div). https://i.stack.imgur.com/yPydJ.png This cool effect is achieved using fixed positioning, but i ...

At a specific media query breakpoint, links are disabled while the rest continue to function without any

Today I encountered a puzzling issue on my website with a responsive layout that utilizes @media queries and breakpoints. At one specific breakpoint (or resolution, as I am still learning the terminology), the links in the navigation bar are inexplicably d ...