CSS 30 ๐ป media queries introduction
a - media queries intro and types
Media queries are a fundamental part of responsive web design
They allow you to apply different styles for different screen sizes and device types
They are defined using @media rule in CSS
media types: all โ applies for all devices(default),
print โ styles for print preview mode screen โ styles for screen devices
in media rules you can also use logical operators โ and, not, only and or
@media screen and (min-width: 780px) โ for screen and min width 780px
@media print โ media query for print version
b - media queries common descriptors
width โ Minimum and maximum width of the viewport. height โ Minimum and maximum height of the viewport.
aspect-ratio โ Aspect ratio of the viewport. orientation โ Orientation (portrait or landscape).
device-width, device-height โ Dimensions of the device screen. color โ Number of bits per color component in the output device.
color-index โ Maximum number of colors that can be addressed on the output device. monochrome โ Number of shades of gray in the output device.
resolution โ Minimum and maximum resolution (dots per inch) of the output device.
scan โ Scan type (progressive or interlaced). hover โ Whether hover capabilities are available.
@media (orientation: landscape) โ only for landscape orientation
@media (min-width: 768px) and (max-width: 1024px) โ for width between 768px and 1024px
@media not (hover: hover) โ for non-touch devices
c - media queries best practices
Mobile First โ Start with the smallest screen and build up to larger ones
Avoid Overusing Media Queries โ Too many can slow down your site...
...Aim for a breakpoint every 50-70 pixels or so.
Use Relative Units โ Use relative units like em, rem, % instead of fixed units...
...like pixels to ensure consistency across different devices.
Test Thoroughly โ Test your designs on various devices and screen sizes to ensure they look good everywhere.
Just remember that media queries are a powerful tool in CSS...
for creating responsive web design
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!