CSS grid - difference between min-content, max-content and fit-content () keywords

Академия мастерства в CSS
Академия мастерства в CSS

Hello, We can use min-content, max-content and fit-content to size text and grid tracks. Example # 1 (no grid) To understand the difference between min-content, max-content and fit-content, lets take a look at some text within a div which is inside container with .no-grid class - if there's no sizing, because our div is a block level HTML element, it just stretches across its container to fit the width of 100px (or whatever width we put on the container) - if we give our div with text width: min-content; the div would shrink to fit the widest (longest) word in that text .no-grid div { width: min-content; } - if we give our div with text width: max-content; and add more text, the div would expand to fit the whole text string. Now if we keep adding more text, the text within our div wouldn't wrap and would eventually overflow the container .no-grid class .no-grid div { width: max-content; } Example # 2 (grid) Now lets take a look at how we can use min-content, max-content and fit-content keywords to control sizing of our grid tracks. We have container with class .grid with 7 divs inside it div class="grid" ****** - if we give our 1st column value of min-content; like so grid-template-columns: min-content 1fr 1fr; the 1st column would shrink to fit the widest (longest) word in that column (same behavior as in our previous example without grid with a string of text) - if we give our 1st column value of max-content; like so grid-template-columns: max-content 1fr 1fr; the grid item would grow to fit the whole text as one line and eventuall would break (overflow) the container (e.g. Lorem50) -we can also use fit-content keyword. this keyword should have length value assigned to it (length unit - px, em, rem or percentages) fit-content (10rem) the way fit-content works is that grid item would keep growing untill it hits the width value defined (10rem) and then text would start to wrap.


Keywords (if available)
Comments

Users Comments

Related Videos

Related videos

Thumbnail

HTML and CSS Tutorial 21: CSS Properties

Learn some of the most common used CSS properties to work with and understand its basics!

By Академия мастерства в CSS

Duration: 17:32

Thumbnail

min-content, max-content, fit-content - intrinsic sizing with CSS

A look at the min-content, max-content, and fit-content values. ? Links ✅ Building the layout: https://youtu.be/sKFW3wek21Q ✅ width auto vs 100%: https://youtu.be/-st14lUQD3U ✅ MDN on intrinsic sizing in CSS: https://developer.mozilla.org/en-...

By Программирование интерфейса с CSS

Duration: 8:51

Thumbnail

CSS Grid For Designers - Minmax, Auto-fit & Auto-fill - Playing Grid Critters Pt. 5

In this video on CSS grid for designers we go over in Grid Critters the minmax, auto-fit, auto-fill, min-content, and max-content properties. The minmax is a function in CSS that lets you define a range of sizes that you might want your columns or...

By Крутые CSS фишки

Duration: 45:43

Thumbnail

3. Intrinsic vs Extrinsic Sizing. Width Auto vs 100%. min-content, max-content, fit-content - CSS3

In this video we will see about the intrinsic sizing and extrinsic sizing. With Auto vs 100%, min-content, max-content, fit-content - CSS3 If you like my video, please subscribe to my channel. Join in the Telegram Group http://t.me/LeelaWebDev My ...

By Техники стилизации

Duration: 12:00

Thumbnail

CSS GRID Урок 6

говорим о параметрах min-content max-content minmax()

By Умный дом: техника, которая упростит вашу жизнь

Duration: 13:41

Thumbnail

CSS : What is the difference between CSS fit-content and max-content?

CSS : What is the difference between CSS fit-content and max-content? [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] CSS : What is the difference between CSS fit-content and max-content? Note: The information provided in ...

By CSS Мастерские

Duration: 1:15

Thumbnail

Min & Max Content Sizing in CSS Grid — 1/3 Flexibility

CSS Grid changes the way flexibility works on the web. When there is more or less space available, Grid allows us to precisely design how content moves. Using simple percent-based widths is not the only option anymore. In the first of a three-part se...

By Эффективный CSS

Duration: 7:42

Thumbnail

CSS Grid - самая понятная инструкция с примерами по гридам (сеткам) в CSS

↓↓↓ Тайм-коды ↓↓↓ В этом уроке мы подробно изучим работу с сеткой CSS Grid. Все на простых и понятных примерах. Тайм коды в описании. :::::::::...

By ВебКадеми

Duration: 49:33

Thumbnail

3 little-known CSS sizing tools

Min-content, max-content, and fit-content size items based on their intrinsic properties, rather than their display properties (e.g., block, etc.). While not always needed when you need these properties, they are a game-changer! --------------------...

By Особенности техники CSS

Duration: 8:54

Thumbnail

CSS Grid - min-content & max-content

Learn min-content and max-content from CSS Grid. Any questions on the above, feel free to contact me on my socials! https://www.instagram.com/paulryancodes/ https://twitter.com/PaulRyan7 https://www.paulryancodes.com Blog Post https://www.paulryanc...

By CSS Чеклист

Duration: 2:37

Thumbnail

CSS GRID. grid-template-column, grid-template-row, minmax, min-content, max-content

CSS GRID. grid-template-column, grid-template-row, minmax, min-content, max-content

By Профессионалы CSS

Duration: 4:48

Thumbnail

CSS Grid Layout Tutorial: Using min-content with minmax function

Responsiveness is important when developing modern website layouts, and that is why in this CSS Grid layout tutorial, I am going to show you how you can make use of the min-content value with the minmax() function that we covered in my last CSS tutor...

By Мастерская CSS

Duration: 11:49

Thumbnail

CSS Grid Layout. Свойства определения сетки grid-template и другие

Продолжаем изучать Grid Layout и сегодня поговорим о свойствах определения сетки, а именно о grid-template-rows, grid-template-columns, grid-template. А так же grid-template-ar...

By Секреты Творческой Мудрости

Duration: 22:40

Thumbnail

Css Tutorial # 27 : Auto-fit & Min-max in Css Grid | Coding PRO

Css Tutorial # 27 : Auto-fit & Min-max in Css Grid | Coding PRO ------ ??? ???? ??????? ------ *Html Coding Full Tutorial : https://bit.ly/34KnlNI *Css Coding Full Tutorial : https://bit.ly/2GNmnYP *For solving any coding problem , learn co...

By все о стилизации кода

Duration: 9:43

Thumbnail

WEB DEVELOPMENT | MIN-MAX CONTENT | CLASS 80 | CSS | SHAN DEVELOPERS

#MinMax #CSS #SDevelopers In this video you will learn how we can use min and max content in Grid

By Объяснение фреймворков JavaScript

Duration: 6:05

Thumbnail

How to use Grid Fit-Content in CSS |fit Content| full tutorial in Urdu and Hindi.

#FitContent#css#GridFitContent Today lecture we are going to learn css fit-content values in Urdu and Hindi.You can learn how to make shrinkable and maximum expandable element width with this new CSS3 property value fit-content.

By Продвинутая работа с CSS

Duration: 6:48

Thumbnail

CSS Grid darslari | 3-dars fr repeat() minmax() min-content max-content

#fr #repeat #minmax #mincontent #maxcontent 00:01:18 - fractions(fr) 00:02:28 - repeat 00:04:43 - minmax 00:08:29 - min-conntent / max-content Assalomu alaykum. Bu dars davomida CSS GRID ning fr, repeat(), minmax(), min-content, max-content haqi...

By CSS создание привлекательных веб-сайтов

Duration: 11:29

Thumbnail

Видео урок по CSS Grid Layout, все свойства css grid, справочник по grid css layout в подарок

Это Видео урок по CSS Grid Layout в котором я расскажу вам про все свойства css grid layout, мы рассмотрим основы grid css и посмотрим как делается css grid ада...

By ITDoctor

Duration: 44:36

Thumbnail

Урок 2. CSS Grid Layout. Свойства grid-template-columns и grid-temaplate-rows

Полный курс по CSS Grid Layout смотрите тут: https://webformyself.com/category/premium/htmlcss-premium/cssgridpremium/ В этом уроке мы более подробно поговорим о возможностях со...

By Секреты Гейминга

Duration: 9:53

Thumbnail

15. CSS Grid Layout. Грид-сетка. Гайд по гридам в CSS

✏️ Разбираем "гриды" в CSS: изучаем понятие сетки, основные термины Grid Layout и все необходимые свойства. 🔴 Timeline: ▶ 00:00 | План урока ▶ 00:1...

By Александр Ламков — Friendly Frontend

Duration: 14:16