Skip to content

row-span-1 not working for grid cell #4437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tian-yan opened this issue May 23, 2021 · 2 comments
Closed

row-span-1 not working for grid cell #4437

tian-yan opened this issue May 23, 2021 · 2 comments

Comments

@tian-yan
Copy link

tian-yan commented May 23, 2021

For example, 10 rows + 1 col grid (grid cell #1 takes 1st row grid cell #2 takes 2nd~9th rows, and last grid cell takes 10th row). If only grid cell #1 has contents (other 2 grid cells <div> have not yet coded), then grid cell #1 will take the full height of screen even though row-span-1 is in place.
Demo code from Tailwind CSS Playground is here.
I want to setup the placeholder even though contents are not yet added, assure 1st grid cell only & always takes desired height. is using h-1/10 class the best practice to achieve so ?
Below Post makes me think whether using grid is recommended / best practice when developing the major layout of webpage. perhaps I should use flex ?

The issue with using flex for grids (which let's be honest is hardly an issue, flex is amazing 😍), is that the margins are don't count as part of the columns. Meaning, you'll get 1/3 + 1/3 + 1/3 plus your margins, which is over 100%. This is causing the wrapping you're seeing.

As you've just noted, you just need to use negative margins and padding:

<div class="flex flex-wrap -mx-4">
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
    <div class="w-1/3 px-4"></div>
</div>

Originally posted by @reinink in #32 (comment)

@tian-yan tian-yan changed the title The issue with using flex for grids (which let's be honest is hardly an issue, flex is amazing 😍), is that the margins are don't count as part of the columns. Meaning, you'll get 1/3 + 1/3 + 1/3 plus your margins, which is over 100%. This is causing the wrapping you're seeing. Fixed height for grid cell May 23, 2021
@tian-yan tian-yan changed the title Fixed height for grid cell row-span-1 not working for grid cell May 23, 2021
@amantiwari1
Copy link

just remove h-screen and it might works

@adamwathan
Copy link
Member

Hey, the issue here is that there is no grid-rows-10 class in Tailwind by default. Once you add it to your config file it works as you'd expect:

https://play.tailwindcss.com/05qi4m09r6?file=config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants