What I'm trying to do using Tailwind CSS is when data is loading, I want to put an animation spin, but the animation -spin I want to be overlay, and in the center.
This is what I have done by far:
<div className="flex justify-center">
<svg
className="animate-spin -inline-block w-8 h-8 border-4 rounded-full"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
></circle>
<path
className="opacity-75"
fill="currentColor"
></path>
</svg>
</div>
By far, the circle is shown on the top center and it's not overlaying at all.
How can I solve this?
You can use animate-spin class.
<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" />
<div class="flex justify-center items-center h-screen fixed top-0 left-0 right-0 bottom-0 w-full z-50 overflow-hidden bg-gray-700 opacity-75">
<div class="spinner-border animate-spin inline-block w-8 h-8 rounded-full" role="status">
<span class="visually-hidden">
<svg
className="animate-spin -inline-block w-8 h-8 border-4 rounded-full"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
></circle>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>
</span>
</div>
</div>
Related
hello community im creating an app using tailwindcss avelte to upload pdf and images using pdfjs and canvas. when im uploading image the absolute element not covering the bottom side of the page
enter image description here
my code is
<div class="absolute w-4/6 justify-center flex items-end mx-auto z-10 bottom-0 inset-x-0">
<div class=" border-2 border-gray-100 flex px- py-4 w-full mx-auto bg-gray-200 xl:flex-nowrap rounded-lg flex-wrap">
<div class="container px-4 mx-auto flex items-center md:flex-row flex-col sm:right-0">
<div class=" flex w-full pr-0 text-center md:mb-0 md:w-auto md:pr-10 md:text-left">
<h1 class="title-font text-2xl font-bold text-red-600 md:text-2xl">Please verify document details before proceed</h1>
</div>
<div class="mx-auto flex flex-shrink-0 items-center space-x-6 md:ml-auto md:mr-0">
<button class=" inline-flex items-center rounded-lg border border-red-600 text-red-600 py-2 px-8 hover:bg-red-600 hover:text-white disabled:cursor-not-allowed disabled:bg-red-200" on:click={releaseDoc} id="release">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" />
</svg>
<span class="title-font ml-2 font-bold text-base">Release</span>
</button>
<button type="button" class="inline-flex items-center rounded-lg border border-green-900 text-green-900 py-2 px-8 hover:bg-green-900 hover:text-white focus:outline-none" id="confirm">
{#if load}
<svg role="status" class="mr-4 h-5 w-5 animate-spin rounded-full border-4 border-white border-r-green-900" viewBox="0 0 24 24" />
{:else}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="h-6 w-6 ">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z"
/>
</svg>
{/if}
<span class="title-font ml-2 font-bold text-base">Confirm</span>
</button>
<button class="inline-flex items-center rounded-lg border border-green-900 text-green-900 py-2 px-8 hover:bg-green-900 hover:text-white focus:outline-none" style="display: none" on:click={getsignature} id="sign">
{#if load}
<svg role="status" class="mr-4 h-5 w-5 animate-spin rounded-full border-4 border-white border-r-green-900" viewBox="0 0 24 24" />
{:else}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
</svg>
{/if}
<span class="title-font ml-2 font-bold text-base">Sign_ID</span>
</button>
<button class="inline-flex items-center rounded-lg border border-green-900 text-green-900 py-2 px-8 hover:bg-green-900 hover:text-white focus:outline-none" style="display: none" id="publish" on:click|once={disablerelease} on:click={publishdoc}>
{#if load}
<svg role="status" class="mr-3 h-5 w-5 animate-spin rounded-full border-4 border-white border-r-green-900" viewBox="0 0 24 24" />
{:else}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.125 2.25h-4.5c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125v-9M10.125 2.25h.375a9 9 0 019 9v.375M10.125 2.25A3.375 3.375 0 0113.5 5.625v1.5c0 .621.504 1.125 1.125 1.125h1.5a3.375 3.375 0 013.375 3.375M9 15l2.25 2.25L15 12" />
</svg>
{/if}
<span class="title-font ml-2 font-bold text-base">Submit</span>
</button>
</div>
</div>
</div>
</div>
if you want this element to cover the whole width you must replace w-4/6 with w-full in first line.
This question already has answers here:
Set opacity of background image without affecting child elements
(15 answers)
Closed 4 months ago.
This post was edited and submitted for review 4 months ago and failed to reopen the post:
Original close reason(s) were not resolved
I'm using flex in tailwind CSS to design the above section. I have placed a background image of React logo in this section. I've tried to change the opacity of the background image through the "opacity-25" class of tailwind but it changes the opacity of the whole section.
Please suggest me a feasible solution for this problem.
Note: Linear gradient isn't applicable here as it will be applied to the whole footer and affect the entire background. I just want to change the opacity of React Logo. I'm using custom classes for "basis". Here "basis-40%" means 40% width of the column.
<div class="flex">
<!-- First col -->
<div class="flex flex-col basis-40% border-solid border-green-900">
<div class="flex">
<img class="w-32 h-22" src="https://cdn.dribbble.com/users/7338576/screenshots/15684153/media/a52985d53636f23a01bed622925099c3.jpg?compress=1&resize=400x300">
<div class="ml-12 flex flex-col">
<div class="flex items-center">
<svg class="w-6 h-6 mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25zm-.53 14.03a.75.75 0 001.06 0l3-3a.75.75 0 10-1.06-1.06l-1.72 1.72V8.25a.75.75 0 00-1.5 0v5.69l-1.72-1.72a.75.75 0 00-1.06 1.06l3 3z" clip-rule="evenodd" />
</svg>
<p class="text-phone-number-color text-lg font-bold tracking-27">0330 057 9957</p>
</div>
<p class="text-email-color my-3 text-lg font-semibold tracking-27">info#aidhumanity.co.uk</p>
<div class="flex">
<svg class="w-6 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25zm-.53 14.03a.75.75 0 001.06 0l3-3a.75.75 0 10-1.06-1.06l-1.72 1.72V8.25a.75.75 0 00-1.5 0v5.69l-1.72-1.72a.75.75 0 00-1.06 1.06l3 3z" clip-rule="evenodd" />
</svg>
<svg class="w-6 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25zm-.53 14.03a.75.75 0 001.06 0l3-3a.75.75 0 10-1.06-1.06l-1.72 1.72V8.25a.75.75 0 00-1.5 0v5.69l-1.72-1.72a.75.75 0 00-1.06 1.06l3 3z" clip-rule="evenodd" />
</svg>
<svg class="w-6 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25zm-.53 14.03a.75.75 0 001.06 0l3-3a.75.75 0 10-1.06-1.06l-1.72 1.72V8.25a.75.75 0 00-1.5 0v5.69l-1.72-1.72a.75.75 0 00-1.06 1.06l3 3z" clip-rule="evenodd" />
</svg>
<svg class="w-6 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25zm-.53 14.03a.75.75 0 001.06 0l3-3a.75.75 0 10-1.06-1.06l-1.72 1.72V8.25a.75.75 0 00-1.5 0v5.69l-1.72-1.72a.75.75 0 00-1.06 1.06l3 3z" clip-rule="evenodd" />
</svg>
</div>
</div>
</div>
<p class="text-footer-links-color text-base font-medium leading-26 tracking-24 mt-12">Aid Humanity is proud to be a non-profit organization that passes 100% of our donations to charitable causes around the world.</p>
</div>
<!-- Second column -->
<div class="flex flex-col basis-10% border-solid border-orange-900 ml-28">
<span class="mb-3 font-semibold text-sm tracking-21">ABOUT US</span>
<div class="text-footer-links-color flex flex-col text-base font-medium leading-30 tracking-24">
<a class="link link-hover">Our Story</a>
<a class="link link-hover mt-1">Marketing</a>
<a class="link link-hover mt-1">Blog</a>
<a class="link link-hover mt-1">Zakat</a>
<a class="link link-hover mt-1 ">Get Involved</a>
<a class="link link-hover mt-1">Contact</a>
<a class="link link-hover mt-1 btn-primary">Donate</a>
</div>
</div>
<!-- Third column -->
<div class="flex flex-col basis-20% border-solidborder-2 border-orange-900 ml-28">
<span class="mb-3 text-link-heading-color font-semibold text-sm tracking-21">APPEALS</span>
<div class="text-footer-links-color flex flex-col text-base font-medium leading-30 tracking-24">
<a class="link link-hover mt-1">Build a Mosque</a>
<a class="link link-hover mt-1">Disaster & Emergency</a>
<a class="link link-hover mt-1">Appeals</a>
<a class="link link-hover mt-1">Water For All</a>
<a class="link link-hover mt-1">Sponsor an Orphan</a>
<a class="link link-hover mt-1">Hunger Appeal</a>
</div>
</div>
<!-- Fourth colmn -->
<div class="flex flex-col basis-10% border-solid border-yellow-900 ml-12">
<span class="mb-3 text-link-heading-color font-semibold text-sm tracking-21">NEWSLETTER</span>
<span class="label-text font-bold text-lg leading-28 tracking-45">Subscribe to the free newsletter and stay up-to date</span>
<div class="flex justify-center mt-5">
<div class="mb-3 xl:w-96">
<div class="input-group relative flex flex-wrap items-stretch w-full mb-4">
<input type="search" class="form-control relative min-w-0 block px-3 py-1.5 text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded-lg transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none" placeholder="Your email" aria-label="Search" aria-describedby="button-addon2">
<button class="btn px-3 ml-2 py-2.5 bg-sky-400 text-white font-medium text-xs leading-tight uppercase rounded-lg shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out flex items-center" type="button" id="button-addon2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor" class="w-4 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3" />
</svg>
</button>
</div>
</div>
</div>
</div>
</div>
And my tailwind.config.js looks like:
/** #type {import('tailwindcss').Config} */
module.exports = {
theme: {
extend: {
colors: {
"footer-links-color": "#8892AC",
"footer-background": "#102558",
"phone-number-color": "#00ADE9",
"email-color": "#FFC100",
"link-heading-color": "#FFFFFF"
},
fontFamily: {
"montserrat": "Montserrat"
},
lineHeight: {
'30': '30px',
'28': '28px',
'26': '26px',
},
letterSpacing: {
'06': '-.06',
'6': '-.6',
'9': '-.9',
'21': '-.21px',
'24': '-.24px',
'27': '-.27px',
'45': '-.45px',
},
flexBasis: {
'10%': '10%',
'15%': '15%',
'20%': '20%',
'30%': '30%',
'35%': '35%',
'40%': '40%',
'50%': '50%',
'60%': '60%',
'70%': '70%',
}
},
},
plugins: [],
}
Although I have never used the tailwind class library, I suspect the css to override the opacity can be done the same way overriding any other value in css can be achieved. Define the selector class at a higher level in the initialization sequence, specify the property and new value and tell the interpreter that it is an important change.
The key takeaway here is the reserved word important which is applied after the new value. This is done by writing a space !important at the end of hte line. More about how !important works can be found at the following website:
https://developer.mozilla.org/en-US/docs/Web/CSS/important
Is it possible to set the height and width of an element and have it shrink when the parent height is smaller than the child height?
I have a reusable icon button component and i want it to have a specific height and width as it is a square.
But when used inside an input element i want it to shrink so it will only use the available space/height of the input element.
Here is a little demo of it.
svg {
width: 1em;
height: 1em;
}
<script src="https://cdn.tailwindcss.com"></script>
<div class="bg-green-200 h-screen p-4 flex flex-col gap-4 items-start">
<button class="inline-flex items-center border border-transparent justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 p-2 text-2xl max-h-16 h-full w-16 bg-white hover:bg-green-50 text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</button>
<div class="mt-1 rounded border-2 border-transparent focus-within:ring-green-500 focus-within:border-green-500 bg-white flex items-center gap-1 p-4 text-lg h-16">
<input id="downshift-1-input" aria-autocomplete="list" aria-controls="downshift-1-menu" aria-labelledby="downshift-1-label" autocomplete="off" class="block w-full focus:outline-none" value="" />
<div class="flex items-center justify-center children:any-h-full h-full text-2xl">
<div class="flex items-center gap-1 text-gray-400">
<button class="inline-flex items-center border border-transparent justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 p-2 text-2xl max-h-16 h-full w-16 bg-white hover:bg-green-50 text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button
><span
><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg
></span>
</div>
</div>
</div>
</div>
I managed to get it to work for the height, but now the width is the problem when i use it in the input element. I tried setting it with max-width, but didn't succeed and i'm a little stuck right now.
Thanks in advance!!
You can use the new css property "aspect-ratio", and set it to "1/1" , it will maintain proportional dimensions while the elements width or height changes depending on its container.
check css-tricks for more details.
To expand on existing answers, you're setting a fixed width on it, but you need to think about the dimensions of this element in terms of aspect ratio, which in your case is 1:1. One way to define it is using Tailwind's utilities for the aspect-ratio property. You need to make sure to propagate h-full all the way to your element so that finally setting h-full on that element has any effect.
The actual changes you need to make is:
add h-full to the Flex container that's wrapping the 2nd close button, this will give effect to the h-full on that button
remove w-16 from both close buttons, because you want the width to depend on the height
instead add aspect-square, which will make width the same as height
If aspect-ratio's browser support isn't acceptable to you, the alternative is to use the padding hack provided by the #tailwindcss/aspect-ratio plugin.
Instead of using fixed values, you could use "100%" for height and width and use fixed pixel values for max-height and max-width. That way the child won't get larger than the parent, but also not larger than the max-values define.
Thanks to the input of Ala Mouhamed and silvenon i managed to get it to work by using aspect-ratio and a fixed height. When using it inside the input field i just pass h-auto to the icon button and override the fixed height. This way it will adjust to the height of the input -> Tailwind Play Demo
svg {
width: 1em;
height: 1em;
}
<script src="https://cdn.tailwindcss.com"></script>
<div class="bg-green-200 h-screen p-4 space-y-4">
<button class="inline-flex items-center border border-transparent justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 p-2 text-2xl h-16 aspect-square bg-white hover:bg-green-50 text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</button>
<div class="mt-1 rounded border-2 border-transparent focus-within:ring-green-500 focus-within:border-green-500 bg-white flex items-center gap-1 p-4 text-lg h-16">
<input id="downshift-1-input" aria-autocomplete="list" aria-controls="downshift-1-menu" aria-labelledby="downshift-1-label" autocomplete="off" class="block w-full focus:outline-none" value="" />
<div class="flex items-center justify-center children:any-h-full h-full text-2xl">
<div class="flex items-center gap-1 text-gray-400">
<button class="inline-flex items-center border border-transparent justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 p-2 text-2xl h-16 h-auto aspect-square bg-white hover:bg-green-50 text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button
><span
><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg
></span>
</div>
</div>
</div>
</div>
</div>
I'm currently in the moment learning tailwind. I'm trying to make these three divs inline when full screen but in smaller screen block. Right now, it is block regardless.
<div {{ $attributes->merge(['class' => 'flex flex-col bg-white dark:bg-gray-800 rounded-lg shadow-xl']) }}>
<div class="text-center items-center px-6 py-3 bg-gray-900 rounded-lg rounded-b-none space-x-12 ">
<div class="sm:inline-flex block items-center">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->likes_count }}</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-6 h-6 text-white">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 5" />
</svg>
</div>
<div class="sm:inline-flex block items-center">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->comments_count }}</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-6 h-6 text-white">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" "/>
</svg>
</div>
<div class="sm:inline-flex block items-center">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->reads }}</span>
<svg class="h-6 w-6 text-white" stroke="currentColor" viewBox="0 0 20 20">
<path d=""></path>
</svg>
</div>
</div>
</div>
If I've understood the documentation right, you use unprefixed utilites to target mobile. Which is block currently and then prefixed larger screen which is sm:inline-flex at the moment, but right now, it displays block either way, what I'm doing worng exactly?
One way to do this is by using flex direction on the parent element for these screen sizes:
<div class="text-center items-center justify-center px-6 py-3 bg-gray-900 rounded-lg rounded-b-none space-x-12 flex flex-col md:flex-row">
<div class="w-100 flex">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->likes_count }}</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-6 h-6 text-white">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2 5" />
</svg>
</div>
<div class="w-100 flex">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->comments_count }}</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-6 h-6 text-white">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
</svg>
</div>
<div class="w-100 flex">
<span class="leading-none text-sm font-semibold mr-2 mt-1 text-white">{{ $post->reads }}</span>
<svg class="h-6 w-6 text-white" stroke="currentColor" viewBox="0 0 20 20">
<path d=""></path>
</svg>
</div>
</div>
Let me know if this works.
I have this output:
What I want to do is centering both those two button at top, and centering that Stop button in the bottom.
I am still new in TailwindCSS, and what I am guessing is I have to use flex, and then centered items in the div beneath that flex div.
For now this is my code:
<div class="space-y-0">
<div class="bg-green-300 w-32 px-2 py-2 rounded-r-2xl mt-2 mr-2 mb-2 align-content-center">
<img src="{% static 'sample/eko.jpg' %}" class="w-32 rounded-r-2xl">
<div class="align-content-center text-center text-green-800">Eko S. W</div>
</div>
<div class="bg-blue-300 mr-2 w-32">
<div class="p-2 flex content-start">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="green">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
</button>
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="green">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11.5V14m0-2.5v-6a1.5 1.5 0 113 0m-3 6a1.5 1.5 0 00-3 0v2a7.5 7.5 0 0015 0v-5a1.5 1.5 0 00-3 0m-6-3V11m0-5.5v-1a1.5 1.5 0 013 0v1m0 0V11m0-5.5a1.5 1.5 0 013 0v3m0 0V11" />
</svg>
</button>
</div>
<div class="text-center font-bold text-2xl text-white">04:51</div>
<div class="flex items-stretch p-2 items-center">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Stop
</button>
</div>
</div>
</div>
i used flex as you can see
<link href="https://unpkg.com/tailwindcss#^2/dist/tailwind.min.css" rel="stylesheet"/>
<div class="space-y-0">
<div class="bg-green-300 w-32 px-2 py-2 rounded-r-2xl mt-2 mr-2 mb-2 align-content-center">
<img src="{% static 'sample/eko.jpg' %}" class="w-32 rounded-r-2xl">
<div class="align-content-center text-center text-green-800">Eko S. W</div>
</div>
<div class="bg-blue-300 mr-2 w-32">
<div class="p-2 flex flex-col justify-center">
<div class="mx-auto"><button >
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="green">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
</button>
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="green">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11.5V14m0-2.5v-6a1.5 1.5 0 113 0m-3 6a1.5 1.5 0 00-3 0v2a7.5 7.5 0 0015 0v-5a1.5 1.5 0 00-3 0m-6-3V11m0-5.5v-1a1.5 1.5 0 013 0v1m0 0V11m0-5.5a1.5 1.5 0 013 0v3m0 0V11" />
</svg>
</button></div>
<div class="text-center font-bold text-2xl text-white">04:51</div>
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Stop
</button>
</div>
</div>
</div>