Not able to position Div using tailwindCSS - css

This is my react code:
<div>
<div>
<div className=" grid gap-4 grid-row-4 grid-flow-col">
<div className="row-span-4 h-2/5 w-auto p-2 bg-white">
<p className="m-4 font-bold">
8 task completed out of 10
<br></br>
<h4 className="font-bold">23 December, Sunday</h4>
</p>
<div className="m-4"> Calender </div>
<div className="m-4 p-4 shadow-md">
<p>
<h4 className="font-bold">Send benefit review by Sunday</h4>
<span className="text-gray-600">
Due date: December 23, 2018
</span>
<br></br>
Image: George Fields
</p>
</div>
<div className="m-4 p-4 shadow-md">
<p>
<h4 className="font-bold">Invite to office meet-up</h4>
<span className="text-gray-600">
Due date: December 23, 2018
</span>
<br></br>
Image: Rebecca Moore
</p>
</div>
<div className="m-4 p-4 shadow-md">
<p>
<h4 className="font-bold">Office meet-up</h4>
<span className="text-gray-600">
Due date: December 23, 2018
</span>
<br></br>
Image: Lindsey Stroud
<h2 className="text-blue-1000 font-bold pt-4"> Show More </h2>
</p>
</div>
</div>
<div className="h-80 w-1/2 p-2 bg-white">
<h4 className="font-bold"> Deals </h4>
<AreaChart />
</div>
<div className="h-80 w-1/2 p-2 bg-white">
<h4 className="font-bold"> Tasks</h4>
<ul className="absolute inset-10">
<li className="text-green-600 font-bold">Active</li>
<li className="text-yellow-600 font-bold">Completed</li>
<li className="text-red-600 font-bold">Ended</li>
</ul>
<PieChart />
</div>
</div>
</div>
</div>
I am not able to position these grids, I don't know where to put the class on and also which classes exactly, please bear in mind this is my day 2 of learning tailwind, any help would be appreciated.
I am also attaching the picture of my UI and will point to the area I want to position this grid layout to. Thanks

I tried to use your code as much as possible, here is the result:
The code:
<div className="flex flex-row ">
<div className="flex flex-col w-96">
<div className="px-2">Placeholder</div>
<div className="px-2">Placeholder</div>
<div className="px-2">Placeholder</div>
<div className="px-2">Placeholder</div>
<div className="px-2">Placeholder</div>
<div className="px-2">Placeholder</div>
</div>
<div className="grid sm:grid-cols-2 bg-gray-200 w-full">
<p className="m-4 font-bold bg-white">
8 task completed out of 10
<br></br>
<h4 className="font-bold">23 December, Sunday</h4>
</p>
<div className="m-4 h-80 w-1/2 p-2 bg-white">
<h4 className="font-bold"> Deals </h4>
AreaChart
</div>
</div>
</div>

Related

I want hover card to animation for images use css tailwind but it don't work

<html>
<body>
<div class="group card my-14 mx-3 w-80 h-100 bg-gray-800 rounded-xl text-white p-5 cursor-pointer">
<div class=" flex justify-between items-center text-2xl ">
<i class='bx bx-heart'></i>
<i class='bx bx-cart-alt'></i>
</div>
<div class="w-11/12 ml-2.5 group-hover:text-white group-hover:-rotate-20">
<img class="object-cover w-full h-full" src="./Images/Jordan.png" id="bannerImage" alt="">
</div>
<div class="text-center uppercase text-xl text-green-600">
Jordan 1 <br>
$299
</div>
</div>
</body>
</html>
Explain why Styling based on parent state doesn't work.
...................................
Tailwind doesn't have -rotate-20 utility class. Change it to one of known or use arbitrary value like group-hover:-rotate-[20deg]

Dynamically changing the height of a div in Tailwind

I have three divs in a grid. the height automatically adjusts to the written content. however, if one div contains too much text, the other two are enlarged incorrectly. I have already tried h-max, h-full and everything else.
Actually, the div in the middle of one of these blocks should be enlarged so that it is always flush at the bottom.
for further information please refer to the picture
<div class="grid grid-cols-6 gap-4">
<div class="bg-green shadow overflow-hidden sm:rounded-lg col-span-2">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-3 font-medium text-gray-100">24 Hours challenge</h3>
</div>
<div class="bg-gray-50 px-4 py-5 text-center">
<a class="text-md font-bold text-gray-500">Ask a stranger if they would like to hear a poem you made. Then improvise a poem if they say yes</a>
</div>
<div class="bg-gray-100 px-4 py-1 text-center">
<a class="text-sm font-medium text-gray-500">06:12:53 left</a>
</div>
</div>
<div class="bg-green shadow overflow-hidden sm:rounded-lg col-span-2">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-3 font-medium text-gray-100">3 Days challenge</h3>
</div>
<div class="bg-gray-50 px-4 py-5 text-center">
<a class="text-md font-bold text-gray-500">Act as if you know a stranger</a>
</div>
<div class="bg-gray-100 px-4 py-1 text-center">
<a class="text-sm font-medium text-gray-500">30:07:00 left</a>
</div>
</div>
<div class="bg-green shadow overflow-hidden sm:rounded-lg col-span-2">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-3 font-medium text-gray-100">Weekly challenge</h3>
</div>
<div class="bg-gray-50 px-4 py-5 text-center">
<a class="text-md font-bold text-gray-500">Sing a song in public</a>
</div>
<div class="bg-gray-100 px-4 py-1 text-center">
<a class="text-sm font-medium text-gray-500">54:06:43 left</a>
</div>
</div>
</div>
flex-grow is the answer thx to Ihar
<div class="bg-gray-50 px-4 py-5 text-center flex-grow">

How to place c2 children to the top and to the bottom of the parent in css?

I need to add 2 children of a parent element one on the top and another on the bottom. something like this.
and this is the code I have.
<div class=" w-full flex justify-betwen bg-white items-center">
<div class="ml-auto">
<img class="object-cover mr-2 md:mr-4 ml-2 md:ml-4 float-left h-40 lg:w-32 w-14 xs:w-16"
src="../img/Bless.png" alt="" />
</div>
<div class="w-full mx-8">
<div class="text-redfull text-ms xs:text-lg md:text-xl lg:text-2xl xl:text-3xl">
Some text here to top as a title.
</div>
<div
class=" text-gray70 flex justify-between items-center text-xs xs:text-base md:text-base lg:text-lg mb-0">
and this is the date to the bottom Uploaded Auguts 4, 2020
</div>
</div>
</div>
Title should stay at the top.
Date to the bottom.
If anyone knows:)
You can add two divs for Title and Date and add vertical margin to them.
I am not sure whether you want with the text or not so I had implemented for both the cases.
Case 1: With text
<script src="https://cdn.tailwindcss.com"></script>
<div class="justify-betwen flex w-full items-center bg-white">
<div class="ml-auto">
<img class="xs:w-16 float-left mr-2 ml-2 h-40 w-14 object-cover md:mr-4 md:ml-4 lg:w-32" src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.s2014.png" alt="" />
</div>
<div class="mx-8 w-full">
<div class="text-3xl font-semibold text-red-900">Your Title here</div>
<div class="my-3">
<div class="text-ms xs:text-lg text-red-500 md:text-xl lg:text-2xl xl:text-3xl">Some text here to top as a title.</div>
<div class="xs:text-base mb-0 flex items-center justify-between text-xs text-gray-500 md:text-base lg:text-lg">and this is the date to the bottom Uploaded Auguts 4, 2020</div>
</div>
<div class="text-base font-extralight">25 June 2022</div>
</div>
</div>
Case 2: Without Text
<script src="https://cdn.tailwindcss.com"></script>
<div class="justify-betwen flex w-full items-center bg-white">
<div class="ml-auto">
<img class="xs:w-16 float-left mr-2 ml-2 h-40 w-14 object-cover md:mr-4 md:ml-4 lg:w-32" src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.s2014.png" alt="" />
</div>
<div class="mx-8 w-full">
<div class="text-3xl font-semibold text-red-900">Your Title here</div>
<div class="my-12">
</div>
<div class="text-lg font-extralight">25 June 2022</div>
</div>
</div>
I had use an online image, so you can replace it with your image.
If You want more gap, then simply increase the my-12 to more.

Responsiveness in tailwind

Hello I'm trying to make responsive websites through tailwind CSS but when I'm dragging the page to small devices the contents are not aligning with the main walls. This is my code-
<div class="navbar flex justify-between items-center p-4">
<div class="hamburger inline-block cursor-pointer md:hidden">
<div class="line h-0.5 w-6 my-1 bg-black"></div>
<div class="line h-0.5 w-6 my-1 bg-black"></div>
<div class="line h-0.5 w-6 my-1 bg-black"></div>
</div>
<div class="logo text-center flex ">
<div>Restaurant</div>
<div
class="nav-links absolute w-fit md:static md:w-auto inset-0 md:flex md:mx-6 md:space-x-6 -translate-x-96 md:translate-x-0">
<div class="links"><a class="link" href="">Services</a></div>
<div class="links"><a class="link" href="">Support</a></div>
<div class="links"><a class="link" href="">Premium</a></div>
</div>
</div>
<div class="link cart text-center md:order-1">Cart</div>
</div>
<div class="slider flex flex-col-reverse justify-around md:flex-row bg-[#ecf0f1]">
<div class="left flex flex-col justify-center items-center md:items-baseline py-12">
<h1 class="text-2xl font-medium md:text-4xl mx-5 text-center">Food on the go</h1>
<p class="text-center md:text-left md:w-3/4 mx-5 my-2">Explore your favourite food and restaurants and
get them delivered at your doorstep.</p>
<button class="bg-black text-white px-5 py-2 my-2 font-bold mx-5 ">Browse</button>
</div>
<div class="right">
<img class="md:w-[50rem]"
src="https://images.pexels.com/photos/1410236/pexels-photo-1410236.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
alt="">
</div>
</div>

CSS alignment: flexbox/ tailwind alignment issues

Currently I'm using tailwind to align data in react, I've tried adding flexbox but it appears im off with a few things
This is my expected outcome:
I would love if someone can explain what im doing wrong as well.
Current outcome:
My last attempt was this:
import React from "react";
import ReactDOM from "react-dom";
const SummaryPerPlatform = () => {
return (
<div>
<div className="max-w-md overflow-hidden bg-white m-4">
<div className="flex flex-col min-h-full">
<div className="flex flex-col flex-grow">
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> Twitter </div>
</div>
<div className="px-6 py-3 border-b">
<span className="">Avg. sentigment(0.0 -1.0)</span>
<span className="">0.31</span>
</div>
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> Instagram </div>
<span className="">Post analyzed</span>
<span className="">5,670</span>
</div>
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> LinkedIn </div>
<span className="">Positive posts (>0.66)</span>
<span className="">1,849</span>
</div>
<div className="px-6 py-3 border-b">
<span className="">Negative posts (0.33)</span>
<span className="">1,981</span>
</div>
</div>
</div>
</div>
</div>
);
};
export default SummaryPerPlatform;
const rootElement = document.getElementById("root");
ReactDOM.render(<SummaryPerPlatform />, rootElement);
Any help is very much appreciated.
You should use flex-row instead of flex-col for whole container. Otherwise I would suggest for using an extra div for differentiating these sections and using Grid to arrange these div in a similar width.
You can try like this:
// ...
return (
<div>
<div className="max-w-md overflow-hidden bg-white m-4">
<div className="grid grid-cols-4 gap-1">
<div>
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> Twitter </div>
</div>
<div className="px-6 py-3 border-b">
<span className="">Avg. sentigment(0.0 -1.0)</span>
<span className="">0.31</span>
</div>
</div>
<div>
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> Instagram </div>
<span className="">Post analyzed</span>
<span className="">5,670</span>
</div>
</div>
<div>
<div className="px-6 py-3 border-b">
<div className="text-xl font-bold"> LinkedIn </div>
<span className="">Positive posts (>0.66)</span>
<span className="">1,849</span>
</div>
<div className="px-6 py-3 border-b">
<span className="">Negative posts (0.33)</span>
<span className="">1,981</span>
</div>
</div>
</div>
</div>
</div>
)
// ...

Resources