-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)
In CSS Grid, columns are the vertical divisions and rows are the horizontal divisions of the grid layout. You define these using:
grid-template-columns
→ defines the number and size of columns
grid-template-rows
→ defines the number and size of rows
They form the structure of the grid and determine how items are placed and sized inside the container.
<div class="grid-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
.grid-container {
display: grid;
grid-template-columns: 100px 100px;
grid-template-rows: 100px 100px;
gap: 10px;
}
This creates a 2-column × 2-row grid with spacing between cells.
Unit | Description |
---|---|
px |
Fixed size |
% |
Relative to the container |
fr |
Fraction of available space |
auto |
Size based on content |
minmax() |
Minimum and maximum range for a track |
fr
grid-template-columns: 1fr 2fr;
Creates two columns — second is twice the width of the first.
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
Automatically adjusts the number of columns based on available space.
grid-template-rows: 150px auto 100px;
Defines 3 rows with different heights.
grid-template
.grid-container {
display: grid;
grid-template: 100px 100px / 1fr 2fr;
}
Rows come before the slash (/
), then columns.
✅ Write CSS for the following:
Q1. Create a 3-column layout with equal width.
Q2. Create 2 rows with fixed height (100px each).
Q3. Make first column 1/3 and second 2/3 of the space.
Q4. Use repeat()
to define 4 equal columns.
Q5. Create 2 columns with min width of 200px, responsive.
Q6. Set 3 rows with heights: 100px, auto, 50px.
Q7. Create a square grid of 3 rows × 3 columns.
Q8. Use grid-template
shorthand for a 2x2 layout.
Q9. Add 20px gap between all rows and columns.
Q10. Combine fr
and auto
in row and column sizing.
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)