skip to Main Content

I want to add justify-between between the hello and the user image & name, they are in different divs but its still not doing much. i tried multiple ways but i can’t seem to get it. Im fairly new so any advice will help

this is what i currently have right now

sorry for the bad drawing but you get the point

import Layout from "@/components/layout";
import {useSession} from "next-auth/react";

export default function Home() {
  const {data: session} = useSession();
  return <Layout>
  <div>
    <div className="text-blue-900 flex justify-between">
      <h2>
        Hello, {session?.user?.name}
      </h2>
      <div className="flex bg-gray-300 gap-1 text-black">
      <img src={session?.user?.image} alt="" className="w-8 h-8"/>
        <span className="py-1 px-2">
        {session?.user?.name}
        </span>
         </div>
        </div>
      </div> 
</Layout>

2

Answers


  1. What’s the width of the parent? I think the issue is coming from the fact that the parent width is too small

    Login or Signup to reply.
  2. Believe parent div is limiting the flex div to take up entire line, consequently your div have no enough space for the space between elements.

    Try to add w-full class on div right after Layout component to test it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search