Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cell in css grid overflow if align-items: end is set

When I use align-items: end in my example, the content overflows and I have no idea why. I expect the same behavior as with align-items: start. I tried setting the width but I couldn’t find a solution.

Here is live demo: https://stackblitz.com/edit/stackblitz-starters-zyhkev?file=index.html

Thanks for your help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

* {
  box-sizing: border-box;
}

.grid {
  display: grid;
  grid-template-columns: 50% 50%;
  gap: 5px;
}

.cell {
  display: flex;
  flex-direction: column;
  border: 1px solid red;
}

.cell.end {
  align-items: end;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
<div class="grid">
  <div class="cell">
    <div>Label</div>
    <div class="ellipsis">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    </div>
  </div>
  <div class="cell end">
    <div>Label</div>
    <div class="ellipsis">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    </div>
  </div>
  <div class="cell end">
    <div>Label</div>
    <div class="ellipsis">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    </div>
  </div>
  <div class="cell">
    <div>Label</div>
    <div class="ellipsis">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    </div>
  </div>
</div>

>Solution :

You need to give the ellipsis class a width. Otherwise it doesnt know where to break. Try:

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading