CSS - Flex items not being affected by justify-content

Working on a small tech challenge and implementing flexbox. Despite setting display: flex; on the parent div, using justify-content with space-evenly in the same CSS property doesn't seem to have any effect.

CSS snippet:

.relatedFlex 
{
  display: flex;
  background-color: #fff;
  justify-content: space-between;
}

HTML portion:

   <section class="relatedPost">
    <div class="wrapper">
        <h2>Related post:</h2>
        <div class="relatedFlex">
            <div class="relatedSectionOne">
                <img class="photoWidth" src="assets/image-2.jpg" alt="Looking Stoic">
                <div>
                    <p>MAR 9, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
            <div class="relatedSectionTwo">
                <img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
                <div>
                    <p>MAR 15, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
            <div class="relatedSectionThree">
                <img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
                <div>
                    <p>MAR 15, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
        </div>
    </div>
</section>

Answer №1

Make sure to specify a width for your related sections

.relatedFlex {
display: flex;
background-color: #fff;
justify-content: space-between;
}

.relatedSectionOne{
width:15vw;
}
   <section class="relatedPost">
    <div class="wrapper">
        <h2>Related post:</h2>
        <div class="relatedFlex">
            <div class="relatedSectionOne">
                <img class="photoWidth" src="assets/image-2.jpg" alt="Looking Stoic">
                <div>
                    <p>MAR 9, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
            <div class="relatedSectionOne">
                <img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
                <div>
                    <p>MAR 15, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
            <div class="relatedSectionOne">
                <img class="photoWidth" src="assets/image-3.jpg" alt="Hands On Learning">
                <div>
                    <p>MAR 15, 2019</p>
                    <h3>Juno Tech Test</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quidem hic natus?</p>
                    <button>Read More</button>
                </div>
            </div>
        </div>
    </div>
</section>

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

Utilizing Multiple Checkboxes for Precision Search Refinement

Big thanks to Khalid Ali for the support provided up until now. I am currently working with an array of songs that each have descriptions, keywords, etc. I have a set of checkboxes that I want to use to refine a search. Essentially, if someone selects the ...

Records were successfully updated and a confirmation message was received, however the changes did not reflect in the database

I am working on creating an "edit_post" page for my website to allow users to edit their previously posted content. Although I receive a notification saying "Updated data successfully," the changes are not being reflected in the MySQL database. <?php ...

The functionality of alpine.js x-for update is not functioning as intended

I have implemented a basic x-for loop on data from the Alpine Store (need it to be global). My objective is to modify a specific row after the table has been rendered by the x-for. Codepen: https://codepen.io/roniwashere/pen/oNMgGyy <div x-data> ...

Is it necessary to reset (local storage, session storage) once the countdown timer reaches zero?

I have successfully implemented a countdown timer using session storage in my code. However, I am looking to enhance its functionality further by: Clearing the local session if the user leaves the site before the countdown timer finishes. Automatically c ...

Setting the title attribute for option elements in a select element that is bound to a model using AngularJs

I'm currently working on an HTML select element that is connected to an ng-model. Here's what the setup looks like: <select data-ng-model="accountType" data-ng-options="at.name for at in accountTypes"></select> This is how my accou ...

Tips for Properly Positioning Floating Pop-Up Messages Using CSS and jQuery

I was experimenting with adding a button that triggers a popup message to my website. I followed a coding tutorial using jQuery and CSS, which looks like this: Javascript : !function (v) { v.fn.floatingWhatsApp = function (e) {...} }(jQuery); CSS : .fl ...

Why does replacing <input> with <TextField> in Material-UI & React cause the form submission to fail?

Recently, I encountered an issue with my CRUD Todo app's form for adding tasks. Initially built with a basic HTML input and button setup, I decided to enhance the design using Material-UI components. After introducing <TextField> in place of th ...

Comparison of Head.js screen size and CSS3 @media query: benefits of prioritizing the former

What are the benefits of using Head.js screen size detection instead of CSS3 media queries? Head.js Screen Size Detection .lt-1024 #hero { background-image: (medium.jpg); } CSS3 @media query @media only screen and (max-width: 1024px) { #hero { back ...

What could be causing WidgEditor, the JavaScript text editor, to fail to submit any values?

After clicking submit and attempting to retrieve text from the textarea, I am encountering a problem where the text appears blank. The reason for this issue eludes me. function textSubmit() { var text = $("#noise").val(); console.log(text); consol ...

Challenge with Hovering within Cufon Elements

When utilizing multiple lists and hover states, the parent Cufon style takes over the child. For instance, in the scenario below, when hovering over the Second Level link, it will switch to a different weight. Is there a setting I can adjust to keep the n ...

Issue with collapsed navbar button functionality in Bootstrap version 5.1.3

Issue with Bootstrap 5 Navbar Collapse Functionality The navbar collapse button is not working on my PC. The button appears but when clicked, the navbar does not show up. Surprisingly, when I test the code on Codeply (without linking to Bootstrap 5 and ot ...

CSS - turn off inheritance for font styling

I am trying to figure out how to turn off the font:inherit property in Ionic's global CSS. This property is causing issues when I try to style text using ng-bind-html, as it adds unnecessary classes to elements like i and bold. I attempted to override ...

CSS alone has the power to make multiple elements react to a hover action on a div

Is there a way to dynamically change the size of multiple div elements on hover? In this example, we can see how one div element's size changes when hovering over another div element: https://jsfiddle.net/9510a6kj/ .left, .right{ float:left; ...

Compass - substitute a single value for an alternate attribute

Can I utilize a value from one class to customize another? Consider the following class: .sourceClass { color: red; } And now, let's say we have this class: .destinationClass { border-color: ###needs to match the color in .sourceClass => re ...

Building a contact table using JSON data

Recently, I embarked on a demonstration project involving HTML, JSON, and jQuery. My current goal is to retrieve data from a JSON file and populate it into a table. Despite my limited experience with JSON, I encountered some difficulties and spent a day tr ...

Setting the default value in the Angular input select

books.component.ts export class BooksComponent implements OnInit { public sortOrder; ... books.component.html <div class="form-group"> <label for="selectOrder">Sort</label> <select class="form ...

Steps to create a fixed pattern background image with a customizable background color based on the content within a div element

I am seeking guidance on how to create a single page application using Angular that features a fixed background image (such as a white pattern) in the BODY tag. However, I would like the ability to change the color behind this image depending on the conten ...

Utilize Angular2's input type number without the option for decimal values

Is there a way to prevent decimals from being entered in number inputs for Angular 2? Instead of using patterns or constraints that only invalidate the field but still allow typing, what is the proper approach? Would manually checking keystrokes with the ...

Adding the target='_parent' attribute to the infowindow of a Google Fusion Map by utilizing a click event listener

As someone who is relatively new to Google Fusion, I am eager to expand my knowledge and skills. Recently, I created a customized map with an infowindow and embedded it onto my website using the FusionTablesLayer Wizard. I wanted to avoid using the target= ...

Add the file to the current directory

As a newer Angular developer, I am embarking on the task of creating a web page that enables users to upload files, with the intention of storing them in a specific folder within the working directory. The current location of the upload page component is ...