MEDIA QUERIES: Enable web pages to adjust their layout and styles based on different screen sizes, devices, or orientations. They are essential for building responsive and adaptable web designs.
- Apply CSS rules conditionally based on screen width or height.
- Help create responsive layouts for mobile, tablet, and desktop devices.
- Support conditions like orientation, resolution, and device type.
- Improve user experience across different devices.
SYNTAX:
@media mediatype and (condition) { /* CSS styles */}
TYPES OF QUERIES IN CSS:
- all.
- print.
- screen.
- speech.
all: Suitable for all media devices.
print: Used for printers.
screen: Targeted at computer screens, tablets, smartphones, etc.
speech: Designed for screen readers that read the content aloud.
EXAMPLE:
@media(max-width:900px){
.sidebar{
display:none;
}
.center{
width:60%;
}
.video-grid{
grid-template-columns:1fr;
}
}
Top comments (0)