2

I have section areas that I want to have equal elements. One side is just an image while the other side has content. I'm using Tailwind CSS and feel positive I have the correct classes. The section Divs are declared as Flex while the child elements each have a Flex-basis of 0 and a Flex grow of 1. The content div continues to be a little larger than my image div.

Current look

 <section class="section-one flex flex-col-reverse md:flex-row-reverse">
  <div class="basis-0 grow p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
    <div>
      <h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
      <p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
      <div class="flex flex-col">
        <a href="#" class="font-fraunces uppercase z-1">Learn More</a>
        <span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
      </div>
    </div>
  </div>
  <div class="basis-0 grow">
    <img src="images/desktop/image-stand-out.jpg" alt="" class="w-full" />
  </div>
</section>
Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79
Jchapa
  • 81
  • 1
  • 2
  • 7
  • Does this answer your question? [How to get flexbox to include padding in calculations?](https://stackoverflow.com/questions/37785345/how-to-get-flexbox-to-include-padding-in-calculations) – Vishal Biswas Apr 09 '22 at 10:20

2 Answers2

1

If you remove your p-6 class and add in the div below it will work.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" integrity="sha512-wnea99uKIC3TJF7v4eKk4Y+lMz2Mklv18+r4na2Gn1abDRPPOeef95xTzdwGD9e6zXJBteMIhZ1+68QC5byJZw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<section class="section-one flex flex-col-reverse md:flex-row-reverse">
  <div class="basis-0 grow remove-this-p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
    <div class="p-6"> <!-- add here your padding -->
      <h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
      <p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
      <div class="flex flex-col">
        <a href="#" class="font-fraunces uppercase z-1">Learn More</a>
        <span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
      </div>
    </div>
  </div>
  <div class="basis-0 grow">
    <img src="https://via.placeholder.com/500" alt="" class="w-full" />
  </div>
</section>

 <section class="section-one flex flex-col-reverse md:flex-row-reverse ">
  <div class="basis-0 grow">
    <img src="https://via.placeholder.com/500" alt="" class="w-full" />
  </div>
  <div class="basis-0 grow remove-this-p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
    <div class="p-6"><!-- add here your pading -->
      <h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
      <p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
      <div class="flex flex-col">
        <a href="#" class="font-fraunces uppercase z-1">Learn More</a>
        <span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
      </div>
    </div>
  </div>
</section>
Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79
0

By using grid you can achieve this

Here is the best explanation how to use grid system in tailwindcss

I have made code for you please check here: https://play.tailwindcss.com/wldkQ1txrU