Skip to content

Needs h-0 class on the wrapping div regardless? #12

Closed
@exalted

Description

@exalted

Watching https://www.youtube.com/watch?v=NX_NW6bt6_s it seemed we could remove also h-0 from the parent element, however, if I do that, then the aspect ratio is not always respected.

In short, I have a grid of 3 columns, where the 2nd column spans to 2:

<div class="grid grid-cols-3">
  <div class="aspect-w-1 aspect-h-1">
    <img
      class="object-cover rounded-lg shadow-lg"
      src="/assets/img/freud.jpeg"
      alt=""
    />
  </div>
  <p class="col-span-2 font-light">
    <span class="italic font-serif"
      >Some text</p>
</div>

So, ideally, I'd expect the image to appear as a square no matter what the viewport size is, however, check out this screen recording as the screen size gets narrower and narrower:

Screenshot 2021-03-16 at 14 46 33

As you can see, Freud's photo, at some point isn't square anymore!

If I add h-0 to the parent div however, so that the code above becomes:

<div class="grid grid-cols-3">
  <div class="h-0 aspect-w-1 aspect-h-1">
    <img
      class="object-cover rounded-lg shadow-lg"
      src="/assets/img/freud.jpeg"
      alt=""
    />
  </div>
  <p class="col-span-2 font-light">
    <span class="italic font-serif"
      >Some text</p>
</div>

Then it works as advertised:

Screenshot 2021-03-16 at 14 49 59

So, I wonder, is this a bug or am I missing something?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions