I am trying to make a flexbox that shows four logos, and aligns them in the middle of the website.
I tried this code:
<div class="text-lg text-ODS-600 bg-ODS-100 rounded-lg p-2 text-center font-bold">
<p>Thanks to:</p>
<div class="flex justify-center">
<div class="flex flex-col lg:flex-row justify-center items-center ">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
</div>
</div>
</div>
no matter what I try, the four logos are always vertically stacked, even on large screens. When I change the code into this, the logos are horizontally stacked:
<div class="text-lg text-ODS-600 bg-ODS-100 rounded-lg p-2 text-center font-bold">
<p>Thanks to:</p>
<div class="flex justify-center">
<div class="flex flex-row justify-center items-center ">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
<img src="images/logo.png" alt="Installation App" class="mb-2 lg:mb-0 lg:mr-2">
</div>
</div>
</div>
What gives? My other parts of the website are nice and reactive (I use the lg: tag regularly, and that works nicely). So, any suggestions why this is not working as it should?
2
Answers
It turns out, it was indeed the installation of tailwind through npm that was faulty. I was outputting the stylesheet in a wrongely named css file, therefore not updating the .css file I needed.
First: notice the height. Try giving a background color to the flex div so you see the space it occupies.
Second: don’t use
justify-center
in your third div, as it may overflow the content vertically (change this in the code below, where it saysjustify-start
and use chrome devtools to see how it renders on a vertical screen).Here is the code I came up with, let me know if this is what you had in mind. Also, I am using the CDN version of tailwind. If it looks weird, try checking your installation.