Tailwind align with Flex (Top, Center, Bottom)

Viewed 1002

I would like to build the following in a container using tailwind. Unfortunately I haven't found a good solution yet. Maybe someone knows more.

enter image description here

  <div class="bg-blue-200 h-48 flex px-8">
        <div class="flex items-top">1</div>
        <div class="flex items-center">2</div>
        <div class="flex items-end">3</div>
  </div>

In the div heading1 one should be at top, heading2 center and heading3 at bottom.

2 Answers

You should use 'flex-col' class.

 <div class="flex flex-col">
      <div class="flex mb-1 bg-blue-200 py-5">Heading 1</div>
      <div class="flex mb-1 bg-blue-200 py-5">Heading 2</div>
      <div class="flex mb-1 bg-blue-200 py-5">Heading 3</div>
  </div>

Demo: https://play.tailwindcss.com/hDdf1puPXP?size=1260x720

This is my proposition with flex flex-col items-center justify-center and custom bg-[colors] and a little white space (padding ,margin). Built with tailwindcss

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.tailwindcss.com"></script>
  </head>

  <body class="bg-[#C3C3C3]">
    <div
      class="flex flex-col items-start justify-center h-screen text-transform: uppercase text-4xl text-white gap-40 ml-10"
    >
      <div class="bg-[#898989] py-5 h-20 w-96 pl-5">Heading1</div>
      <div class="bg-[#898989] py-5 h-20 w-96 pl-5">Heading2</div>
      <div class="bg-[#898989] py-5 h-20 w-96 pl-5">Heading3</div>
    </div>
  </body>
</html>

Related