Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TikTina's avatar

How can I glue input next to a div, CSS, tailwind

How can I basically glue these to elements one next to each other like in the next picture? The first one is an input, and the second is a div. I use tailwind https://imgur.com/a/RI0ClKk

like this:

https://imgur.com/a/1Lbgfup

0 likes
6 replies
tykus's avatar

Wrap the input and div inside another div; and add a border, e.g.

<div class="flex border border-gray-300">
  <input type="text">
  <div>hello</div>
</div>

A Tailwind input should have no styles by default.

tykus's avatar

@TikTina if you make the input grow, then inner divs will fill the outer one.

<div class="flex border border-gray-300">
  <input type="text" class="flex-grow">
  <div>hello</div>
</div>

Just grow if you're using tailwindcss v3

TikTina's avatar

@tykus Oh, I understand it, but the thing is I need to specify my width for my input because if I leave it widthless it will be too wide.

tykus's avatar
tykus
Best Answer
Level 104

@TikTina set a width on the parent; or make the parent inline-flex

<div class="border border-gray-300 inline-flex">
  <input type="text" class="w-64">
  <div>hello</div>
</div>
1 like

Please or to participate in this conversation.