-
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)
Media Queries are a key component of Responsive Web Design (RWD). They allow you to apply different CSS rules depending on the device’s characteristics, such as:
Screen width
Device type (screen, print)
Orientation (portrait or landscape)
Resolution or pixel density
They help your layout adapt to different screen sizes, making it mobile-friendly and user-friendly across all devices.
@media (condition) {
/* CSS rules go here */
}
@media (max-width: 768px) {
body {
background-color: lightblue;
}
}
This changes the background color only if the screen width is 768px or less.
Feature | Description |
---|---|
max-width |
Applies if the screen is less than or equal to given width |
min-width |
Applies if the screen is greater than or equal to given width |
orientation |
Detects screen orientation: portrait or landscape |
max-height |
Applies based on screen height |
resolution |
Targets screen pixel density (e.g., Retina) |
body {
font-size: 18px;
}
@media (max-width: 600px) {
body {
font-size: 16px;
}
}
/* Desktop */
.container {
display: flex;
}
/* Tablet */
@media (max-width: 992px) {
.container {
flex-direction: column;
}
}
/* Mobile */
@media (max-width: 600px) {
.container {
padding: 10px;
}
}
@media (orientation: landscape) {
.video-player {
width: 80%;
}
}
✅ Use em
or rem
units instead of px
for better scalability
✅ Start with a mobile-first approach using min-width
✅ Organize media queries by breakpoints: mobile, tablet, desktop
✅ Avoid too many breakpoints — use them only when necessary
✅ Write CSS to handle these situations:
Q1. Hide a sidebar on screens smaller than 768px
Q2. Change body background color only on tablets
Q3. Resize image to 100% width on mobile devices
Q4. Stack two columns vertically on small screens
Q5. Change font size for headings on large desktops
Q6. Adjust padding and margin for small screens
Q7. Show a hamburger icon below 600px screen width
Q8. Apply dark background only in portrait mode
Q9. Make navbar fixed only on desktop
Q10. Hide a banner on screens wider than 1200px
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)