I am uncertain as to why `Justify-Between` insists on aligning everything at the start of the container

While utilizing tailwind css, I am encountering a problem where my justify-between behaves like justify-start. However, when I switch to using justify-end, it aligns everything to the end of the container.

I would appreciate it if someone could point out what I might be overlooking and explain why my Logo and Navigation components are not correctly separating into distinct areas?

Navbar.jsx

import React from "react";
import Logo from "./Logo";
import headerLogo from "../../assets/images/headerImages/phreaquencyLogoDark.png";

const Navbar = () => {
  return (
    <nav className=" bg-off-white dark:bg-off-black">
      <div className="container w-full px-6 py-4 mx-auto md:flex md:justify-between md:items-center">
        <div className="flex items-center justify-between">
          {/* Logo Div */}

          <a
            className="text-2xl font-bold text-gray-800 transition-colors duration-200 transform md:hidden dark:text-white lg:text-3xl hover:text-gray-700 dark:hover:text-gray-300"
            href="#"
          >
            Phreaquency
          </a>
          <div className="hidden md:flex">
            <Logo
              logoSrc={headerLogo}
              logoAltSrc="phreaquency logo"
              logoLayout="intrinsic"
              logoObjectFit="contain"
              logoWidth="150px"
              logoHeight="40px"
              className="relative z-10 flex items-center w-auto"
            />
          </div>
          <div className="flex md:hidden">
            <button
              type="button"
              className="text-gray-500 dark:text-gray-200 hover:text-gray-600 dark:hover:text-gray-400 focus:outline-none focus:text-gray-600 dark:focus:text-gray-400"
              aria-label="toggle menu"
            >
              <svg viewBox="0 0 24 24" className="w-6 h-6 fill-current">
                <path
                  fillRule="evenodd"
                  d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z"
                ></path>
              </svg>
            </button>
          </div>

          {/* Navigation Div */}
          <div className="items-center md:flex">
            <div className="flex flex-col md:flex-row md:mx-6">
              <a
                className="my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0"
                href="#"
              >
                Home
              </a>
              <a
                className="my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0"
                href="#"
              >
                Shop
              </a>
              <a
                className="my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0"
                href="#"
              >
                Contact
              </a>
              <a
                className="my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0"
                href="#"
              >
                About
              </a>
            </div>
          </div>
        </div>
      </div>
    </nav>
  );
};

export default Navbar;

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

Answer №1

Attempt to insert a dividing div with the class flex-1 in between the two existing divs:

import React from 'react';
import Logo from './Logo';
import headerLogo from '../../assets/images/headerImages/phreaquencyLogoDark.png';

const Navbar = () => {
  return (
    <nav className=' bg-off-white dark:bg-off-black'>
      <div className='container w-full px-6 py-4 mx-auto md:flex md:justify-between md:items-center'>
        <div className='flex items-center justify-between'>
          {/* Logo Div */}

          <a
            className='text-2xl font-bold text-gray-800 transition-colors duration-200 transform md:hidden dark:text-white lg:text-3xl hover:text-gray-700 dark:hover:text-gray-300'
            href='#'
          >
            Phreaquency
          </a>
          <div className='hidden md:flex'>
            <Logo
              logoSrc={headerLogo}
              logoAltSrc='phreaquency logo'
              logoLayout='intrinsic'
              logoObjectFit='contain'
              logoWidth='150px'
              logoHeight='40px'
              className='relative z-10 flex items-center w-auto'
            />
          </div>
          <div className='flex md:hidden'>
            <button
              type='button'
              className='text-gray-500 dark:text-gray-200 hover:text-gray-600 dark:hover:text-gray-400 focus:outline-none focus:text-gray-600 dark:focus:text-gray-400'
              aria-label='toggle menu'
            >
              <svg viewBox='0 0 24 24' className='w-6 h-6 fill-current'>
                <path
                  fillRule='evenodd'
                  d='M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z'
                ></path>
              </svg>
            </button>
          </div>

          {/* Separator div */}
          <div className='flex-1'></div>

          {/* Navigation Div */}
          <div className='items-center md:flex'>
            <div className='flex flex-col md:flex-row md:mx-6'>
              <a
                className='my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0'
                href='#'
              >
                Home
              </a>
              <a
                className='my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0'
                href='#'
              >
                Shop
              </a>
              <a
                className='my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0'
                href='#'
              >
                Contact
              </a>
              <a
                className='my-1 text-sm font-medium text-gray-700 transition-colors duration-200 transform dark:text-gray-200 hover:text-blue-500 dark:hover:text-blue-400 md:mx-4 md:my-0'
                href='#'
              >
                About
              </a>
            </div>
          </div>
        </div>
      </div>
    </nav>
  );
};

export default Navbar;

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

How can I incorporate Algolia Places integration with react-instantsearch?

Looking for a simple example of how to use Algolia Places with react-instantsearch? I've been trying to combine the two, but I'm stuck on what to use and how. The docs mention that we need an HTMLInputElement as a required container option, but h ...

Inject CSS values dynamically

I am currently working on dynamically setting the color of a div. To provide some context, let's examine the following: <!doctype html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <div clas ...

The issue I am facing involves a 404 not found axios error when attempting to send a post request

I am attempting to send data via a post request from react.js to express.js using axios, but I keep encountering a 404 not found axios error. You can view the error image here. Below is my code: export default function Upload() { const [state, setState ...

How to implement caching for Stripe JS V3 in Next.js with Server-Side Rendering

I am utilizing a getServiceSideProps function to display a complex APP that interacts with an API: const MyApp: NextPage = (props: any) => { let stripePromise: any; const getStripe = async () => { if (!stripePromise) { str ...

Utilizing a ListView Below a LinearLayout: Step-by-Step Guide

In my Android project, I am working on creating the MyProfile activity. This activity will display a user's profile picture, name, and other bio data on the first screen. Additionally, I would like to make the layout swipeable so that when the screen ...

Is there a way to integrate Javascript code with a React component?

I need to find a way to include this block of code in just one specific React component. Any suggestions? <!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. --> <button sty ...

What steps should I take to show a particular set of data upon selecting a checkbox component?

I have a table with a column named status, which can be in progress, pending, or dispensed. https://i.sstatic.net/1mMNQ.png My goal is to filter the data based on the checkbox that is selected above the table. For instance, if I check the "pending" check ...

Error on-fly.io: Next.js build encounters a hiccup when pre-rendering a route that interacts with

Recently I embarked on my journey with fly.io and here is my current setup: In my next.js (app folder), I have a route that executes a simple SELECT * FROM test using the pg package. I utilized fly launch to set up an app and postgres app. However, my loc ...

React Component that closes when it loses focus

In my React project, I am working on creating a custom select2 style component. Most of the functionality is complete, but I am struggling with figuring out how to hide the result box when the user clicks away. Here is the render method: render() { l ...

Creating a photo grid with consistent order is simple using flexbox

I'm currently working on an image grid that consists of 2 rows laid out horizontally. Initially, the first row contains 4 images while the second row has 2 images. Users should have the ability to add more images to the second row. The issue I am faci ...

React router updates the URL without affecting the actual display

I am facing an issue in my React project where the URL changes when clicking a link, but the view does not update. I have a separate route and links file, and I can't seem to figure out the problem. Here is my index.js: import React from 'react ...

What is the best way to expand the width of my Bootstrap 4 navbar dropdown menu?

Need help creating a full-width dropdown for a Bootstrap 4 navbar using the standard boot4 Navbar? Check out the navbar template I am currently working with. Here is an example of how I want it to look: Desired design image link <nav class="navbar fix ...

How is it possible to retrieve the flex-direction property value of a div using JavaScript?

While attempting to troubleshoot this issue using Windows Chrome 59, I utilized devtools to examine the properties. let element = document.getElementById("divId"); Upon checking the value of the element, I noticed that the object structure displayed: &g ...

Styling various versions of a <button> using Styled Components

In my app, I have a basic colored button that needs to change its color depending on the UI state: const StyledButton = styled.button` & { border: 0; color: white; cursor: pointer; } &:hover { background-color: ${(props) => ...

I'm having trouble connecting to port 3000 on my Docker container from the browser

I have dockerized my application using Laravel, Nginx, and MySQL. Below are the docker-compose file and Dockerfiles used: docker-compose.yaml version: '3.8' services: # Application app: container_name: app build: context: . ...

My form does not receive the Bootstrap classes when using the jQuery script

**Why isn't my jQuery script coloring the rows as expected when certain conditions are met (I italicized the specific part of the code)?** Here is the HTML CODE for the POLL: <form id="pollForm" class="mb-4"> <d ...

Building with Webpack on a started Express server can be achieved by following these steps

Hello there, I am diving into the world of React and Webpack. My configuration in `webpack.config.js` looks like this: const webpack = require('webpack'); const path = require('path'); module.exports = { cache: true, entry: { ...

I'm new to REact js, wondering how I can modify state object values as I iterate through an array containing their keys

import React from 'react'; import Button from '@material-ui/core/Button'; const items=['update','status'] export default class MyComponent extends React.Component{ constructor(props){ super(props) ...

Generate dynamic routes in Next.js only when needed

I'm currently working on a project using NextJS to create a frontend for a database that contains thousands of products, with the expectation of significant growth. The site/products/ route is functioning well, but I wanted to add a route to view indi ...

What is the best way to eliminate data from a channel title using jQuery?

$(function() { $(".track").draggable({ containment:"document", appendTo:document.body, connectToSortable:"#playlist tbody", revert: true, revertDuration: 0, cursor: "move", helper: "clone", ...