The display:flex property with justify-content:space-around is malfunctioning in React and causing issues

I've been trying to troubleshoot the issue with my header, but so far I haven't found a solution.

Could you please take a look at my code first?

// Code simplified for clarity, no need to worry about variables

const Header = () => {
  return (
    <header className={styles.headerContainer}>
      <nav className={styles.navContainer}>
        <h1>Frontend Quiz !</h1>
        <p>{currentStage} / 10</p>
          <Link to='/'>
            <button type='button'>Quit</button>
          </Link>
      </nav>
    </header>
  )
}

export default Header
@use '/src/styles/constants/colors';

.headerContainer {
  position: fixed;
  width: 100%;
  height: 60px;
  padding-top: 20px;
  color: colors.$TOPNAV;
  background: colors.$WHITE;

  .navContainer {
    display: flex;
    justify-content: space-around;
    color: colors.$TOPNAV;

    button {
      font-size: 16px;
      color: colors.$TOPNAV;
    }
  }
}

https://i.sstatic.net/nEdG8.png

Despite using display: flex and justify-content: space-around, it's not displaying correctly.

The 1 / 10 should be centered between the other two elements, but it's not working as expected.

If there's something I missed or if I'm doing something wrong, please point it out. Thanks!

Answer №1

Thank you for reaching out.

Your code appears to be wanting to create space around the Paragraph element and all buttons inside it.

You might want to check if your structure should resemble something like this:

<div className="spaceAroundClass">
 <h1>Welcome Message</h1>
 <div>Middle Section</div>
 <div>Button Container</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

Encountering issues with implementing useStyles in Material-UI components

Currently, I am working on a project utilizing Material-UI's library and encountering styling issues. This project marks my initial venture into ReactJS and JavaScript in general. Therefore, any assistance would be greatly appreciated! I am struggli ...

troubles with dividing string

Recently delving into JavaScript/Angular development and encountering a little roadblock. I am attempting to break up a string of a textarea into an array at the \n character within a controller by utilizing $scope.mytext.split("\n"), however, I ...

JQuery Function for Repeatedly Looping through Div Elements

I've been experimenting with creating a loop that alternates the fade-in and fade-out effects for different elements. This is what I have so far: setInterval(function() { jQuery(".loop").each(function(index, k) { jQuery(this).delay(1200 ...

What are your thoughts on Uptrends vs Dynatrace for Website Monitoring?

I'm seeking recommendations for improving monitoring on a retail website. Any advice would be appreciated. Thank you in advance. ...

Tips on configuring commas in the Prettier extension within Visual Studio Code

My CSS file is causing me some trouble. I am trying to configure Prettier in VS Code so that when I write a comma, the selector I entered stays in line with the previous one. However, whenever I save the file, the selector gets moved to the next line. My ...

Managing promise errors by verifying the response

I am currently facing an issue where I need to handle inappropriate responses in the 'then' block of the code snippet below. getData().then(response => transformData(response)); I believe I need to implement something like this, but I am uns ...

What is the process for saving appends to variables and converting them to PHP for storage in a database?

<html> <head> <meta charset="utf-8"> <title>Test page for Query YQL</title> <link rel="stylesheet" href="http://hail2u.github.io/css/natural.css"> <!--[if lt IE 9]><script src="http://hail2u.github.io ...

Execute --runTestsByPath on two or more distinct paths

Currently, I am utilizing the jest cli for running my tests. Jest offers a useful cli option known as --runTestsByPath, which allows me to specify the locations of my tests. Despite having unit tests spread out in various directories within my repository, ...

How to eliminate column padding in Bootstrap 4

Can you help me with a layout challenge I'm facing? I have two columns set up like this: <div class="row"> <div class="col-6"> hello </div> <div class="col-6"> hello ...

Styling the footer of a webpage using CSS to adapt to different browser

I am currently working on a webpage that includes a footer. The footer is positioned correctly, but I encounter an issue when resizing the browser from bottom to top. For further details, please refer to the image below: Below is the CSS code for my foote ...

In React, the goal is to render nested data recursively and retrieve the "name" from a JSON file

How can I extract a list of "name" values from this JSON list? [ { "id": "LIB1", "name": "Library 1", "context": "C1", "children": [ { "id": "SKI1", "name": "SKill 1", ...

Numerous Fascinating Challenges with React Native

Looking to share my React Native project and seeking help with some issues I'm facing. Despite multiple attempts, I have been unsuccessful in resolving them. Can anyone provide assistance? I have thoroughly searched Stack Overflow for similar questio ...

Troubleshooting CSS issues in a Docker container running a VueJs project

I have successfully set up a VueJs project on AWS using Docker. Following the guidelines in the Real-World Example section of the documentation, I created a Dockerfile with instructions to copy my nginx conf file: # build stage FROM node:lts-alpine as buil ...

I'm wondering why my typography components display correctly on my local host, but not on my aws server. Any insights on

I've encountered an issue with the typography component I'm using for my headings. When I publish the website, the headings do not render properly and the styles are not applied correctly. Strangely, everything looks fine during npm run dev, but ...

Uncertainty arises from the information transmitted from the controller to the Ajax function

In one of my coffee scripts, I have an AJAX call that calls a method in a controller. The AJAX call is structured like this: auto = -> $.ajax url : '<method_name>' type : 'POST' data : <variable_name> ...

Encountering the error code 'ERR_EMPTY_RESPONSE' while utilizing an AJAX-powered live search feature

My website features a live AJAX search bar that retrieves records from a MySQL database. However, when users repeatedly conduct searches by modifying the search criteria, some web browsers display an error message stating 'ERR_EMPTY_RESPONSE'. ...

Troubleshooting error in data structure for nested dynamic routes with Next.js getStaticPaths

I am working on a page called [categories][price].js and I am attempting to achieve a particular data structure within the getStaticPaths function. For example, I want to have paths like cat1/10, cat1/20, cat1/30, cat2/10, cat2/20, etc. I came across this ...

Unlock maximum screen viewing on your custom video player with these steps to activate fullscreen

I'm having an issue with my basic video player - when toggling fullscreen, it doesn't fill the whole screen even though I tried using .fullscreen{width:100%} without success after searching for a solution. html <div class='player-contai ...

utilizing a Bootstrap modal element throughout multiple HTML documents

I have a bootstrap modal dialog div that I want to use in all 4 html pages of my web application without repeating the code. I have a common JavaScript file for this purpose. What is the best way to achieve this? <!-- Modal --> <div class="modal ...

The tab functionality in Bootstrap is malfunctioning

Struggling with implementing tab functionality on my navigation bar using Bootstrap. The tab links change the URL, but the content of the tabs doesn't update accordingly. I'm using Bootstrap 4 - do I need to add jQuery code to make this work? Wha ...