Can't style rectangle properly
Unanswered
Acorn-plum gall posted this in #help-forum
Acorn-plum gallOP
Hello everyone, I am currently making a website using next js, typescript, tailwindcss and daisyui. I have made a navbar that is responsive, it changes size regardless of screen size so I tried to make a rectangle below that navbar component in my home page but I was struggling for hours trying to make it not change size at any size level. Can someone help me?
24 Replies
American Chinchilla
Can you drop the code of what you have currently?
@American Chinchilla Can you drop the code of what you have currently?
Acorn-plum gallOP
ah hello
here is page.tsx
import NavBar from "./components/navbar";
export default function Home() {
return (<main>
<NavBar />
<div className="absolute w-40 h-20 bg-blue-500"></div>
</main>
)
}
export default function Home() {
return (<main>
<NavBar />
<div className="absolute w-40 h-20 bg-blue-500"></div>
</main>
)
}
here is navbar.tsx
import Link from "next/link";
import React from "react";
interface Props{
children?: React.ReactNode
home? : React.ReactNode
about? : React.ReactNode
}
const NavBar : React.FC<Props> =({children = 'Serious Web App', home = 'home', about = 'about'}) => {
return (
<div className="navbar bg-blue-300">
<div className="flex items-center justify-between w-full">
<Link href="/" className="btn btn-active btn-ghost normal-case text-xl text-white">{children}</Link>
<Link href='/'className="ml-auto text-xl text-white" >{home}</Link>
<Link href='/about' className="ml-5 mr-40 text-xl text-white">{about}</Link>
</div>
<div className="flex-none"></div>
</div>
)
}
export default NavBar
import React from "react";
interface Props{
children?: React.ReactNode
home? : React.ReactNode
about? : React.ReactNode
}
const NavBar : React.FC<Props> =({children = 'Serious Web App', home = 'home', about = 'about'}) => {
return (
<div className="navbar bg-blue-300">
<div className="flex items-center justify-between w-full">
<Link href="/" className="btn btn-active btn-ghost normal-case text-xl text-white">{children}</Link>
<Link href='/'className="ml-auto text-xl text-white" >{home}</Link>
<Link href='/about' className="ml-5 mr-40 text-xl text-white">{about}</Link>
</div>
<div className="flex-none"></div>
</div>
)
}
export default NavBar
@American Chinchilla Can you drop the code of what you have currently?
Acorn-plum gallOP
uh hello?
sorry for not responding for so long
American Chinchilla
And what's the output look like rn?
Acorn-plum gallOP
Like this
first one is at 100 percent zoom , second one is at 33 percent zoo
I want that rectangle to not change size at all
Look at how the navbar responds but not that rectangle
American Chinchilla
Right now it's technically not changing size at all, the screen is just getting larger. If you want it to maintain the same relative size to the screen, use % based width. w-1/3 is the tailwind class for 33% width.
Tailwind Docs on width: https://tailwindcss.com/docs/width
Tailwind Docs on width: https://tailwindcss.com/docs/width
If there's a certain width you want that's not listed there you can do something like w-[43%]
Acorn-plum gallOP
Oh ok
Thank you so goddamn much
But still I want it to conver the entire horizontal space it can
how to do that?
American Chinchilla
100% or screen
w-full or w-screen
Acorn-plum gallOP
Oh ok
thanks man you are a life saver
American Chinchilla
np