Issue with Applying CSS Flexbox Justify-Content: Flex End

I'm having trouble achieving the design I created in Figma: https://i.sstatic.net/aH6Cy.png

Instead, my actual code output looks like this (dummy text): https://i.sstatic.net/z5L0y.png

This is the CSS and SCSS for my page:

.navbarcont {
    margin-top: 2em;
    display: flex;
    background-color: hsl(206, 97%, 13%);
    border-radius: 34px;
    width: 80vw;
    height: 3em;
    margin-left: auto;
    margin-right: auto;
    

    .links {
        display: flex;
        justify-content: flex-start;
        margin-left: 2em;
        align-items: center;
    }

    ul {
        display: inherit;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1em;
    }

    .langcont {
        display: inherit;
        justify-content: flex-end;
        align-items: center;
    }
}

Here's the React HTML code I'm using:

<div className="navbarcont">
                    <div className="links">
                        <ul> {/*TODO: Remember to put icons before the a tags! (USE BOOTSTRAP ICONS!) */}
                            <li>
                                <a href="#">Hello</a>
                            </li>
                            
                            <li>
                                <a href="#">Hello</a>
                            </li>

                            <li>
                                <a href="#">Hello</a>
                            </li>
                        </ul>
                    </div>

                    <div className="langcont">
                        <div className="langtext">
                            <p>Language Select</p>
                        </div>
                    </div>
                </div>

I can't figure out why justify-content: flex-end; isn't working for the langcont class.

Any help would be greatly appreciated. Thank you!

Answer №1

To achieve the desired layout, make sure to include an extra justify-content property within the navbarcontent class.

.navbarcont {
  ...
  justify-content: space-between;
}

By doing this, you will create a space between the two divs and your elements should be displayed as intended.

Answer №2

To achieve the desired layout, apply the justify-content: space-between CSS property to the .navbarcont class.

.navbarcont {
  display: flex;
  justify-content: space-between;
...
}

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

What is the best practice for importing modules in React Native: MainActivity.java or MainApplication.java?

While integrating this module into my React Native project, the documentation suggests importing it in MainActivity.java. However, in my previous project where I have used it, I imported all modules including this one in MainApplication.java. In which fi ...

Having difficulty implementing a personalized color scheme for the mui component

Attempting to set the background color as midnightBlue but encountering an error: Error: Cannot read properties of undefined (reading '100') Upon reviewing the syntax, no errors were found. Perhaps this issue stems from a dependency problem? ...

Struggling to properly test the material-ui datagrid component using react-testing-library

I'm facing an issue while testing the content of my material-ui datagrid. Only the first 3 out of 8 columns are displayed in the test, but everything appears fine on a web browser. I suspect that the problem might be related to the width and height ...

store JSON data within an HTML list element

I've been working on a JavaScript script that allows me to generate list items in HTML. Right now, I have functionality to drag and remove the items using another script. However, I am interested in adding some additional information to each list item ...

Styling Material UI icons: Tips and Tricks

What is the best way to position a material ui icon in the middle of a button? import AddIcon from '@material-ui/icons/Add'; <Button><AddIcon style={{ bottom: 3, right: 3 }}/>ADD</Button> click here for an image preview ...

How to stop the overflow scrollbar in a grandchild element with CSS grid

Encountered an unusual issue while using a combination of CSS grid and overflow auto. In the scenario where there are 3 elements, the outermost element has display: grid, the middle element has height: 100%, and the innermost element has both height: 100% ...

Looking for guidance on building a real-time React application with automatic data fetching linked to a nodejs backend

I have a simple question, I have developed an app that retrieves data from a backend server, Now, the app needs to be accessed and edited by multiple users simultaneously while ensuring that all changes made to the list are reflected in real-time for ever ...

Error with adaptable menu

I am attempting to develop a responsive menu similar to the Bootstrap nav bar using only CSS. I have managed to get the functionality working, but the positioning of the menu grabber is incorrect and I'm unsure how to correct it. The grabber should al ...

Tips for personalizing Material-UI and styled-components styles using prop-based customization

Utilizing Material-UI and styled-components, I encountered a scenario where I needed to override the styles of a Material-UI component with styled-components based on a passed prop. Initially, my attempt involved passing an additional prop to the styled-c ...

Having trouble selecting the button in Material UI DatePicker with React Testing Library

Trying to implement tests for a React component that serves as a wrapper around Material UI's KeyboardDatePicker using React Testing Library has brought about challenges. The main issue faced is the inability to select the button responsible for openi ...

Prevent unauthorized entry to css and javascript files

Is there a way to prevent direct access to a file? I want the file to be used on my website, but I want to block it from being accessed directly. For example, if you try to open this link: https://example.com/style.css, you will see an error message. Howev ...

Utilizing React Native for Geolocation in Foreground Service without Timeout

Encountering an issue and struggling to find a solution. My goal is to continuously track the user's location every 30 to 60 seconds using a foreground service that displays a notification, ensuring the user is aware of the tracking. The foreground s ...

Issue: ParserError encountered due to a Syntax Error found at line 1, column 32

As a beginner in programming, I am encountering an issue. When I run "npm run build" in the Terminal to compress my project in React.js, I encounter this error. Interestingly, I have previously created another project without facing this problem, and I can ...

What is the relationship between getStaticPaths and getStaticProps in Next.js?

Although I have gone through the Next.js docs and am familiar with getStaticProps and getStaticPaths, I'm still unsure about how they work in conjunction. Specifically, I'm curious about when exactly getStaticProps is triggered (particularly when ...

Having trouble decoding image data with CameraRoll.saveToCameraRoll in React Native?

There is a warning message displaying Possible: Unhandled Promise Rejection: Error: Error decoding image data This snippet of code is causing the issue. for (let media of mediaArray) { await CameraRoll.saveToCameraRoll( 'https://someurl.mp ...

Vue's v-model functionality encounters issues when navigating back and forth in the browsing history

Below is a sample of code from the local index.html file: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">< ...

When the click event is triggered, the second function guess() does not execute

I am currently developing a number guessing application. It consists of two functions, the first one called startGame() works correctly (it receives the maximum number and then disappears by adding the hidden class). However, the second function that is ...

Optimizing HTML and Script loading sequences for efficient execution

I have a query regarding the loading order of scripts in web browsers. I am interested in knowing the most efficient way to redirect users to a mobile website on the client side. For example, if I place a mobile detection script within the <head> se ...

Creating a fantastic Image Gallery in JavaScript

As I work on creating a basic gallery page with html and css, everything seemed to be running smoothly. However, upon testing it in Google Chrome and IE, the onmouseover function is not responding as expected. The idea is for a larger image to display in t ...

Utilize the material-ui dialog component to accentuate the background element

In my current project, I am implementing a dialog component using V4 of material-ui. However, I am facing an issue where I want to prevent a specific element from darkening in the background. While I still want the rest of the elements to darken when the ...