Tailwind space-4-x -> first item not getting the space applied

Viewed 66
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.tailwindcss.com"></script>
    <title>Document</title>
  </head>
  <body>
    <div class="flex space-x-4 flex-col">
      <div>Item</div>
      <div>Item</div>
      <div>Item</div>
      <div>Item</div>
      <div>Item</div>
      <div>Item</div>
      <div>Item</div>
    </div>
  </body>
</html>

This is my markdown. It should be reproducible. My Problem is that the first item does not get the spacing applied. Every other item does get the space applied. Am I doing something wrong here? I want ALL the items to have space.

enter image description here

1 Answers

Try

<div class="ml-4">
   <div>Item</div>
   <div>Item</div>
   ...etc.
</div>

Nice nuance find. space-x-4 is behaving as expected - it's for putting space between items horizontally, so the intended use case is all your divs are on the same line.

enter image description here

space-x-4 is just applying left and right margin to all items after the first

Related