Align items on the same line in mobile view #3261
-
Hi Tailwind friends, I am a bit of a CSS noob, so please be patient with me! I am trying to build a navbar with an icon and a button and want it to show up on the same line (whether its at small or large form factors). I am using Tailwind 2.0.2. However, I am unable to align the Can someone tell me what I am missing here? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey! The problem is that on mobile view, you have both the logo and the button as flex containers, instead of sitting within the same flex parent. I copied your CodePen code over to a Tailwind Play example, and here's what I modified in the mobile view:
Here's the code where you can see your layout working properly: https://play.tailwindcss.com/jR7mLtn93t Hope it helps 👍 |
Beta Was this translation helpful? Give feedback.
Hey!
The problem is that on mobile view, you have both the logo and the button as flex containers, instead of sitting within the same flex parent.
I copied your CodePen code over to a Tailwind Play example, and here's what I modified in the mobile view:
flex justify-start
andflex justify-end
utilities on the logo / button elementsflex justify-between
classes insteadflex-1
to the logo element to make it take all the available space outside of the button, so both elements are left and right aligned.Here's the code where you can see your layout working properly:
https://play.tailwindcss.com/jR7mLtn93t
Hope it helps 👍