CSS fit-content() Function
- Previous Page CSS exp() function
- Next Page CSS grayscale() function
- Go Up One Level CSS Function Reference Manual
Definition and Usage
CSS fit-content()
The function allows the size of the element to be adjusted according to the content. This method is similar to the element using the available space, but it will never exceed the maximum content size.
Example
Using fit-content()
Adjust the size of the columns in the grid:
#container { display: grid; grid-template-columns: fit-content(250px) fit-content(250px) auto; grid-gap: 7px; box-sizing: border-box; height: 150px; width: 100%; background-color: green; padding: 7px; }
CSS Syntax
fit-content(length|percentage)
Value | Description |
---|---|
length | Specify the absolute length value of the size. |
percentage | Specify the percentage size relative to the available space. |
Technical Details
Version: | CSS4 |
---|
Browser Support
The numbers in the table indicate the browser version that first fully supports this function.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
57 | 16 | 52 | 10.1 | 44 |
Related Pages
Reference:CSS grid-auto-columns attribute
Reference:CSS grid-auto-rows attribute
Reference:CSS grid-template-columns attribute
Reference:CSS grid-template-rows attribute
- Previous Page CSS exp() function
- Next Page CSS grayscale() function
- Go Up One Level CSS Function Reference Manual