-
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)
A Responsive Grid View is a layout that adjusts the number of columns and the size of items based on the screen size or device width. It is widely used for:
Image galleries
Product listings
Portfolio layouts
Blog post grids
Cards and dashboards
With CSS Grid or Flexbox, we can make grids that automatically adjust on mobile, tablet, and desktop.
%
, fr
, or auto
instead of fixed px
.<div class="grid">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
.grid {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.item {
flex: 1 1 calc(25% - 10px); /* 4 columns */
background: #ddd;
padding: 20px;
box-sizing: border-box;
}
@media (max-width: 768px) {
.item {
flex: 1 1 calc(50% - 10px); /* 2 columns */
}
}
@media (max-width: 480px) {
.item {
flex: 1 1 100%; /* 1 column */
}
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
This allows the number of columns to auto-adjust based on screen size.
✅ Use auto-fit
or auto-fill
✅ Keep minimum column width using minmax()
✅ Always define gap
between items
✅ Use box-sizing: border-box
to avoid width overflow
✅ Test your layout on multiple devices
✅ Write HTML/CSS for the following:
Q1. Create a 3-column grid that adjusts to 2 columns below 768px and 1 column below 480px.
Q2. Make an image gallery with equal-sized responsive grid items.
Q3. Build a card layout using Flexbox grid with wrapping.
Q4. Use auto-fit
with minmax(150px, 1fr)
to create a dynamic grid.
Q5. Add space between grid items using gap
.
Q6. Use media queries to change the number of columns.
Q7. Make the grid container full width and center the items.
Q8. Add hover effects to grid items that scale on hover.
Q9. Create a grid where the first item spans two columns.
Q10. Combine grid layout with responsive images inside each item.
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)