What is the best way to display an income statement div with three elements in a vertical position once the screen reaches a medium width?

Can anyone help me create an income statement div with three elements that has a responsive layout? I want these elements to change from a horizontal display to a vertical one when there is limited space, especially on medium width screens.

The initial layout should look like this:

+10,000 Supported Companies +14 Countries Served +250 Million Managed

Once the medium device width is reached, I need the layout to switch to:

+10,000 Supported Companies

. +14 Countries Served

. +250 Million Managed

I want to avoid having an intermediate layout where elements are split unnaturally. I've tried using the following CSS settings but haven't been successful:

Any advice on achieving this desired behavior would be greatly appreciated. Thank you!

#results-1 {
  width: 100%;
  gap: 1rem;
  padding: -10px -10px 0.7rem 1.8rem;
}

#results-2 {
  gap: 3.5rem;
  font-weight: bold;
  font-size: 1.5em;
  margin-right: 29px;
  padding-right: -20px;
  text-decoration: underline 5px;
}
<div className=' d-flex flex-column' id='results-1'>
  <div className=" d-flex justify-center" id="results-2">
    <span id="emp" className='col-10 col-sm-4 col-md-4 col-lg-4'> +10,000 Supported Companies </span>
    <span id='paiat' className='col-10 col-sm-4 col-md-4 col-lg-4'>+14 Countries Served </span>
    <span id='money' className='col-10 col-sm-4 col-md-4 col-lg-4'>+250 Million Managed </span>
  </div>
</div>

Answer №1

After investigating, I discovered that when the width is below 826px, the elements start breaking. To address this issue, we need to include display: block inside the media query for the elements (specifically the spans) to move onto a new line. The revised code following my analysis of the demo site looks like this:

#results-1 {
  width: 100%;
  gap: 1rem;
  padding: -10px -10px 0.7rem 1.8rem;
}

#results-2 {
  gap: 3.5rem;
  font-weight: bold;
  font-size: 1.5em;
  margin-right: 29px;
  padding-right: -20px;
  text-decoration: underline 5px;
}


/*responsive code from here*/

@media (max-width:1148px) {
  #results-1 {
    margin-left: auto !important; /*forced because there an important here*/
  }
  #results-2 {
    display: block !important; /*forced for the same reason*/
    margin-left: auto;
    margin-right: auto;
  }
  div#results-2 span {
    display: block;
    width: auto;
    text-align: center;
    padding: 20px 0; /* the gap between the lines*/
  }
}

@media (max-width:383px) {
  div#results-2 span {
    font-size: 6vw !important; /*responsive font size*/
  }
}
<div className=' d-flex flex-column' id='results-1'>
  <div className=" d-flex justify-center" id="results-2">
    <span id="emp" className='col-10 col-sm-4 col-md-4 col-lg-4'> +10,000 Supported Companies </span>
    <span id='paiat' className='col-10 col-sm-4 col-md-4 col-lg-4'>+14 Countries Served </span>
    <span id='money' className='col-10 col-sm-4 col-md-4 col-lg-4'>+250 Million Managed </span>
  </div>
</div>

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

I am trying to connect HTML input with Python but I am not sure how to do it

As part of our capstone course team project, we are developing a self-hosted calendar app specifically designed for college students. One of our team members has taken the initiative to create HTML webpages for this self-hosted server. My current task is t ...

Having trouble with tabs in jQuery?

I'm having trouble setting up tabs in a reservation form with 3 tabs that include text boxes for user input. I can't seem to get it working properly and I'm not sure where I've gone wrong. Could it be due to the placement of the content ...

Utilize NodeJS to redirect external asset requests to the local filesystem

Consider this scenario: We are tasked with fetching an image from an S3 bucket. <img src="https://s3-us-west-2.amazonaws.com/{BUCKET}/logo.png" /> Due to limited internet connectivity, I must find a way within my Express server to redirect requests ...

Visual Composer in WordPress is not displaying as expected

I've attempted to uninstall and reinstall Visual Composer, but I'm unable to resolve the issue. I can't edit the front end because it's not displaying properly. I'm using the Ken theme. When checking the console, I encountered this ...

Verifying unloaded images

I am new to using Selenium and I need help. I am attempting to retrieve all the image sources on a page in order to identify any images that have not loaded. How can I check the image sources? Can I use "null" as a check? Below is my code, which contains m ...

Bizarre Incident Management

My latest project involves a simplistic website featuring arrow images (png) positioned on the left and right sides with fixed placement, allowing users to navigate to the next page. However, an issue arises where the cursor seems unable to select the an ...

Float a div within text to be positioned vertically

Is there a way to use only CSS to create an article that includes a featured quote section starting around 50px from the top? The section should be half the width of the page with text wrapping around it at the top and bottom. Currently, I am using the fl ...

Is there a file outside of the website's root that needs to be linked?

Hey there, I could use some assistance with a little issue I am having: Running the latest release of Ubuntu server 64bit with 2 virtual websites Here is my folder structure: site1 (Accessible on the web) /var/www/site1 site2 (Intranet site) /var/www ...

Is there a way to modify the browser's user agent using JavaScript or HTML?

I currently have an application that is running on IE7. However, an analytics tool I rely on has recently been updated and now requires a minimum of IE8. Is there a way to modify the User Agent in IE7 using JavaScript or HTML to trick it into being recogni ...

Tips for assigning a string value to an <li> element with Jquery

I have a database table structured as follows: ID name aa1 Tom bb2 Jack cc3 Mike To display this data in an HTML format, I am using Ajax to pass the values. $.ajax({ ... success: function (data) { $.each(data, f ...

What is the best way to define a:link style within a div class structure?

I am trying to include an anchor tag within my HTML... Inside the tag, I have the following CSS code: .foo { white-space:nowrap; text-shadow: 0 -1px 0 #000; color: #000; font-family: Helvetica Neue, Helvetica, arial; font-size: ...

Problem with background video height on Elementor for Wide screen resolutions

Hello, I trust this message finds you in good health. I have a question regarding the video background on wide/big screens. The issue is that it displays correctly on all devices in Elementor settings and actual testing, except for widescreen LCDs, where ...

What could be causing the issue of my CSS file not properly connecting with my HTML files in Django?

I am facing an issue with linking the CSS file to the HTML file in my code. Despite not showing any errors, there is no effect on my webpage. The files I have included are settings.py, base.html, and base.css. Additionally, my static folder is located outs ...

The floating left div displays oddly when it wraps onto the next line

I currently have a variable number of floating divs, ranging from 1 to 10. When I display either 1-5 or all 10, they appear correctly: item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 However, when I try to display around 7 of them, things s ...

Issues retrieving information from MySQL through an AJAX request

I am encountering an issue while attempting to fetch data from a database. The code seems to only retrieve the initial row of data and not any subsequent rows. Although the data is correct, it remains the same regardless of the input provided in the HTML f ...

Issue with Wordpress css rendering on Internet Explorer

My webpage is functioning well in Chrome and Firefox, but I'm facing compatibility issues with Internet Explorer. I've identified several bugs related to tables and layout, however, I'm struggling to resolve the font and text-transform prob ...

javascript guide to dynamically update the glyphicon based on value changes

I am attempting to implement an optimal level feature where a glyphicon arrow-up will be displayed if a value falls within the optimum range, and it will switch to a glyphicon arrow-down if the value is lower. <div class="card-body" ng-repeat="item i ...

Customizing the appearance of charts in AngularJS using the Chart.js

I just started experimenting with AngularJS and recently created a horizontal bar chart using Chart.js and HTML. My next step is to make the chart dynamically appear on the page with the help of AngularJS. Can someone please provide some guidance on how I ...

What is the best way to retrieve the URL from a specific HTML tag?

I am attempting to extract all URLs that have id='revSAR' from the provided HTML tag using a Python regex: <a id='revSAR' href='http://www.amazon.com/Altec-Lansing-inMotion-Mobile-Speaker/product-reviews/B000EDKP8U/ref=cm_cr_dp ...

Diagram with Cascading Style Sheets and Hypertext Markup Language

As I work on creating a flowchart, here is the code that I have developed: #flowchart { width: 580px; text-align: center; font-family: sans-serif; font-size: .8em; margin: auto; } #flowchart a { ...