Hi I'm trying to have an easy app takes 100% of my screen width so that it is can be centered horizontally. But right now my app keeps only using like 1/5 of my screen width starting on the left.
My app component calling my only other component ProfileSection
function App() {
return (
<main className="flex h-screen justify-center items-center bg-gray-100">
<ProfileSection
profilePicUrl={pp}
currentFollowers={137}
goalFollowers={200}
/>
</main>
);
}
export default App;
return (
<section className="bg-black w-full">
<div className="max-w-4xl mx-auto flex flex-col items-center gap-6">
<img
src={profilePicUrl}
alt="Profile"
className="w-32 h-32 rounded-full border-4 border-blue-500 shadow"
/>
<div className="w-full px-4">
<div className="flex justify-between text-sm text-gray-600 font-medium mb-1">
<span>{currentFollowers} followers</span>
<span>Goal: {goalFollowers}</span>
</div>
<div className="w-full bg-gray-200 h-4 rounded-full">
<div
className="h-4 bg-blue-500 rounded-full transition-all duration-500"
style={{ width: `${progressPercent}%` }}
></div>
</div>
</div>
</div>
</section>
);
EDIT: Added index.css
content
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
width: 100%;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
@import "tailwindcss"
There are two ways to make it work.
I have created base Vite project, so I guess your setup is same.
<div id="root"></div>
in your index.html
, one way could be to add#root {
width: 100%;
}
w-screen
to your main
element in App.jsx
<main className="flex w-screen h-screen justify-center items-center bg-gray-100">