Our logo Kybercode
Home
Archive
Articles
Shared
Bits
About
Contact
Home
Archive Articles Shared Bits

About
Contact
RSS
Search
CSS Web Dev
Cooper Gidge on May 28, 2025.

So overflow-wrap: break-word and CSS Grid don't work well together. But using minmax(0, 1fr) instead of just 1fr fixes it.

This defaults the min-width of the column to 0 instead of auto. For whatever reason, min-width: auto causes problems.

<div class="grid">
    <div><p>Without <code>minmax(0, 1fr)</code></p></div>
    <div><p>This div contains a very long word: someveryveryveryveryveryverylongword</p></div>
</div>
<div class="grid grid-2">
    <div><p>With <code>minmax(0, 1fr)</code></p></div>
    <div><p>This div contains a very long word: someveryveryveryveryveryverylongword</p></div>
</div>
.grid {
    display: grid;
    /* this doesn't work... */
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: 400px;
    margin-bottom: 8px;
}
.grid div {
    /* overflow-wrap: break-word isn't working... */
    overflow-wrap: break-word;
    border: 3px dashed #FF0000;
}
.grid-2 {
    /* this DOES work... */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
}
false
Result

Comments

There are no comments yet. Be the first to post one!

Leave a Comment

Thank you for posting a comment! It will be reviewed and if it passes our checks, it'll be published.

Replying to

This will be publicly displayed with your comment.

Contribute to the conversation! Markdown supported.

Keep Reading

Previous Why I'm Close to Abandoning Cloud Computing

By Cooper Gidge on May 28, 2025.

Next What's the difference between readonly and disabled in form controls?

By Cooper Gidge on May 4, 2025.

Browse More
The AI Bubble Burst, Just Not In The Way I Was Expecting

By Cooper Gidge on Jan 28, 2025.

Why I Don't Use JavaScript Frameworks

By Cooper Gidge on Jan 19, 2025.

How To Automate Open Graph Images With Eleventy

By Cooper Gidge on Dec 5, 2024.

Featured
Logo Kybercode

All things about software and website development.

RSS
Resources
Home Archive Articles Shared Bits Topics
About
About Contact
Copyright © 2025 Kybercode
Privacy Policy
Home
Archive
Articles
Shared
Bits