- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - min-content Property
The CSS min-content is a value that can be used for sizing properties to specify the minimum size of a box or element based on its content.
It specifically suggests that text content will make use of soft-wrapping opportunities, which enable the material to resize to the length of its longest word. The min-content value is calculated based on the intrinsic minimum size required by the content inside the box.
Syntax
/* Used as a length */ width: min-content; inline-size: min-content; height: min-content; block-size: min-content; /* Used in grid tracks */ grid-template-columns: 100px 2fr min-content;
CSS min-content - Box Sizing
The following example demonstrates the use of min-content keyword for box sizing.
<html> <head> <style> body { background-color: #b9cded; font-family: 'Helvetica Neue', Arial, sans-serif; margin: 0; padding: 20px; } .container { width: 100%; display: flex; flex-direction: column; align-items: flex-start; } .item { width: min-content; background-color: #ffffff; padding: 5px; margin-bottom: 20px; border: 1px solid #e0e0e0; box-shadow: 0 3px 6px rgba(0, 0, 0, 1); color: #444444; border-radius: 8px; } </style> </head> <body> <div class="container"> <div class="item">Min-Content Example.</div> <div class="item">Well-Crafted Min-Content Example.</div> <div class="item">Thoughtfully Presented Min-Content Example.</div> </div> </body> </html>
CSS min-content - Sizing Grid Columns
The following example demonstrates the use of min-content keyword for sizing grid columns.
<html> <head> <style> body { margin: 0; font-family: 'Arial', sans-serif; background-color: #f9f9f9; } #container { display: grid; grid-template-columns: 1fr min-content min-content; grid-gap: 15px; box-sizing: border-box; max-width: 800px; margin: 20px auto; padding: 20px; background-color: #f2f2f2; border: 1px solid #82807f; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); border-radius: 8px; } .item { background-color: #5f9ea0; color: #141414; padding: 15px; border-radius: 5px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); } </style> </head> <body> <div id="container"> <div class="item">Flexible Content Area</div> <div class="item">Min-Content 1 Content Area</div> <div class="item">Min-Content 2 Content Area</div> <div class="item">Dynamic Content Area</div> <div class="item">Min-Content 3 Content Area</div> <div class="item">Min-Content 4 Content Area</div> </div> </body> </html>
Advertisements