Skip to content
Submitted about 2 months ago

Advice generator app - Next.js + Tailwind + Shadcn

next, tailwind-css, shadcn, fetch
LVL 2
A solution to the Advice generator app challenge

Solution retrospective


What challenges did you encounter, and how did you overcome them?

I struggled a bit with the position of the button. I found out the browser positions the left edge of your button at the 50% mark of the parent container. This means the button starts at the center and extends to the right.

To truly center it, you need to move the button backwards (to the left) by exactly half of its own width. Using -translate-x-1/2 fixes it!

<button 
  onClick={handleNewAdvice}
  disabled={isLoading}
  className={`absolute -bottom-8 left-1/2 -translate-x-1/2 w-fit p-5 bg-primary-green-300 rounded-full cursor-pointer duration-200 ${!isLoading && 'hover:shadow-neon hover:shadow-primary-green-300'}`}
  aria-label="Generate new advice"
>
Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Fernando Pérez Mojica’s solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord