Difficulties encountered when trying to align the content within a div

I am struggling to align the content within three horizontal divs on an info bar. The center div should be aligned center and the right-hand div should be aligned to the right, but my CSS attempts have not been successful.

My attempts included adding text-align:center to #delivery and text-align:right to #quickshop, as well as trying float:right on #quickshop, but none of these worked.

Here is a snippet of the HTML/CSS code:

#info-bar {
    height: 46px;
}
#container {
    margin: 0 auto;
    width: 82%;
}
.info {
    float: left;
    width: 37.5%;
    margin: 0;
    padding: 9px 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
}
#quickquotes.info {
    width: 28.5%;
}
#quickshop.info {
    width: 34%;
}
#container i {
    font-size: 34px;
    color: #a6d120;
    display: inline-block;
    vertical-align: middle;
}

#container i:before {
    position: relative;
    top: 0px;
}
.icon-quote:before { content: url("http://placehold.it/35x27"); }
.icon-delivery:before { content: url("http://placehold.it/35x27"); }
.icon-quickshop:before { content: url("http://placehold.it/35x27"); }

#container .text-area {
    display: inline-block;
    text-align: left;
    margin-left: 0px;
    color: #1e3e57;
    letter-spacing: 0.07em;
    font-weight: bolder;
    text-transform: uppercase;
    font-size: 0.8em;
} 
<div id="info-bar">
  <div id="container">
    <div id="quickquotes" class="info">
      <i class="icon-quote"></i>
      <div class="text-area">
        Quick Quote Fast Response</div>
    </div>

    <div id="delivery" class="info">
      <i class="icon-delivery"></i>
      <div class="text-area">
        Free UK Delivery on Orders Over £100</div>
    </div>

    <div id="quickshop" class="info">
      <i class="icon-quickshop"></i>
      <div class="text-area">
        Quick Shop Search Product Codes</div>
    </div>
  </div>
</div>

A live example of the issue can be seen in this fiddle: https://jsfiddle.net/qafru72o/2/

I am unsure of where I am making a mistake with the alignment. Any guidance would be appreciated.

Answer №1

Eliminate the text-align:left; styling from the #container .text-area selector and then apply justify-content to each individual div.

#info-bar{
    height: 46px;
}
#container{
    margin:0 auto;
    width:82%;
}
.info{
    float:left;
    width:37.5%;
    margin:0;
    padding: 9px 0;
    display:flex;
    flex-wrap: nowrap;
    align-items: center;
}
#quickquotes.info{
    width:28.5%;
    justify-content: flex-start;
}
#quickshop.info{
    width:34%;
    justify-content: flex-end;
} 
#delivery.info{
    justify-content: center;
}
#container i {
    font-size: 34px;
    color: #a6d120;
    display: inline-block;
    vertical-align: middle;
}
#container i:before {
    position:relative;
    top:0px;
}
.icon-quote:before     {content: url("http://placehold.it/35x27");}
.icon-delivery:before  {content: url("http://placehold.it/35x27");}
.icon-quickshop:before {content: url("http://placehold.it/35x27");}

#container .text-area {
    display: inline-block;
    margin-left: 0px;
    color:#1e3e57;
    letter-spacing:0.07em;
    font-weight:bolder;
    text-transform:uppercase;
    font-size:0.8em;
}
<div id="info-bar">
  <div id="container">
    <div id="quickquotes" class="info">
      <i class="icon-quote"></i>
      <div class="text-area">
        Quick Quote Fast Response</div>
    </div>

    <div id="delivery" class="info">
      <i class="icon-delivery"></i>
      <div class="text-area">
        Free UK Delivery on Orders Over £100</div>
    </div>

    <div id="quickshop" class="info">
      <i class="icon-quickshop"></i>
      <div class="text-area">
        Quick Shop Search Product Codes</div>
    </div>
  </div>
</div>

Does this meet your requirements?

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

Extraction of Canonical URLs

I am completely new to VBA programming and I need assistance with extracting links related to specific keywords from a website. My goal is to have these sourced links as the final outcome for all keywords in my list using a VBA program. The code I've ...

Trimming content within an editable div in JavaScript: A guide

I am working on an editable div feature where users can input text for comments. My goal is to eliminate any unnecessary spaces before and after the text. For example, if a user types: "&nbsp;&nbsp;Hello&nbsp;world&nbsp;&nbsp;&nbsp ...

Organize table information using rowspan functionality

View of Current Table I am looking to implement a side column in my table using rowspan to group dates within each pay period. The goal is for a supervisor to be able to create a new pay period, which will assign a unique integer in the database and then ...

Styling with react-jss based on intricate conditionals

After experimenting with react-jss for a few weeks, I am faced with the challenge of styling components efficiently. With numerous conditionals in these components, I am striving to avoid creating an excess of new components that essentially share the same ...

Solution: Resolve clientY scrolling issue within an HTML document

I am facing an issue with the positioning of my context menu. When I right-click and scroll down, the menu does not maintain its regular position. Instead of appearing to the right of the mouse cursor when stationary, it moves below the cursor based on how ...

I'm experiencing an issue where the links in my dropdown button are not showing when I hover over it. What could

I have been attempting to include a dropdown button that reveals several links when the mouse hovers over it. Despite successfully implementing the CSS for this feature, I am encountering an issue where the links are not displayed beneath the button. Afte ...

What is the best method for deleting scripts to optimize for mobile responsiveness?

My current plugin.js file houses all my plugins for responsive design, but it is unnecessarily large and cumbersome for mobile devices. I am considering creating two separate plugin.js files to toggle between for mobile and desktop views. What are the r ...

The navigation bar appears to have a different width on mobile view specifically on one page

I created a mobile view navigation that appears correctly on two out of three pages. It spans the full 100% width as intended, but on one page it extends beyond that and causes the layout to look distorted due to the larger navigation bar. I'm not sur ...

Collaborative spreadsheet feature within a browser-based software platform

I am using an Angular-based SPA for my web application. My goal is to be able to open an Excel file within the application itself. Currently, I have a menu button or link that is linked to a specific path, for example //192.168.10.10/sharedExcels/myExcel. ...

When invoking a function that has been returned, the error message "invalid function" is displayed

I've been working on a wordle-style game, but I'm running into an issue with fetching the API and getting the validation functions to work properly. Every time I press submit, I keep getting an error saying "getData(...).isCorrect is not a functi ...

Eradicate white space in a JavaScript code

Calling all JS programmers! Here's a challenge for you, check out this demo: https://codepen.io/gschier/pen/jkivt I'm looking to tweak 'The pen is simple.' to be 'The pen issimple.' by removing the extra space after 'is& ...

An algorithm designed to evenly distribute items among multiple arrays when the number of items is less than the number of arrays

Looking for an algorithm in PHP that can evenly distribute items across multiple arrays while skipping arrays if the number of items is less than the number of arrays. Here's a hypothetical scenario to illustrate my problem: Scenario: Imagine there ...

A Comprehensive Guide on Creating an Expansive HTML Textbox Covering the Entire

<form method="post" class="mobile-login-form _5spm" id="u_0_0" novalidate="1" data-autoid="autoid_1"> <input type="hidden" name="lsd" value="AVpe_Wp1" autocomplete="off"> <input type="hidden" name="charset_test" value="€,´,€,´, ...

Executing a Javascript function when a form is submitted

function validateForm() { alert("Form submitted successfully"); return true; } <form onsubmit="return validateForm()" action="add.php" method="post" id="p1"> <center>Add New Survey</center> <p>&nbsp;&l ...

Modify anchor link color in a one-page website by using Jquery to detect scroll position changes when reaching different page sections

Each if statement contains specific numbers to change the text color of the visited/current/active anchor link. The height of the page is dependent on its width. How can this be resolved? Apologies if my explanation is confusing, English isn't my stro ...

Utilizing Next.js Image Component to Apply CSS for Width and Height Settings

Currently, I am utilizing the Image component provided by Next.js, which requires setting specific width and height values. To address this, I am incorporating Tailwind CSS utility classes to establish the desired dimensions. https://i.sstatic.net/A28fB.j ...

Could you please provide me with the option to send a list of the

Is there a way to send output via email instead of displaying it in the following div: <div id="fullCalendar" ></div> After spending a whole night searching online, I couldn't find a solution. As I'm not very familiar with jQuery pr ...

Is there a way to programmatically toggle a button's enabled state depending on the content of a text input field?

I want to create a functionality where a button will be enabled if the value in a textbox is 'mypassword'. If it's not equal to 'mypassword', then the button should be disabled. I've attempted the code below, but it doesn&apos ...

JavaScript tool for connecting tags with JSON properties

As a beginner in JS, I am curious if there exists a JS library that can help bind html fields to a JS object. For example: <div class="js_source"> <input field="name" /> <input field="surname" /> <button type="button">S ...

Assigning the "action" attribute of a form to direct to the homepage

Working on a login form, I've encountered an issue with the action attribute when set to "index.cfm". This seems to work fine for all other pages except for the index page. Looking for some insights if anyone else has faced this problem before. I&apos ...