- Mastering PostCSS for Web Design
- Alex Libby
- 236字
- 2021-07-14 11:12:27
Revisiting media queries
If you spend any time viewing sites on different devices, then it will hardly come as a surprise to see media queries in the style sheet—they form the basis for responsive design and declarations allow us to control what is displayed on screen, according to the available screen width.
The principles behind media queries are simple. In a nutshell, we have to define the device or media, and the resolution (or width) at which point the rule (or breakpoint) either kicks in or stops being applied. Take this simple example:
@media only screen and (max-width: 768px) { /* CSS Styles */ ... }
Any styles within will be applied only when we're viewing on screen, and our available screen estate is 768px
or less. This is a simple example, they can be as simple or as complex as required; it's down to us as developers to work out exactly where our content breaks and to build a suitable breakpoint to manage the change.
Note
To get a feel for some of the more recent media queries that are possible, take a look at this post by Chris Coyier, who has queries for laptops, PCs, and even wearable devices! The list is available at https://css-tricks.com/snippets/css/media-queries-for-standard-devices/.
Okay, let's make a start: PostCSS makes it easy to manage queries for both text and images; we'll begin our journey with a look at handling images.
- Python入門很簡單
- MySQL 8從入門到精通(視頻教學版)
- Functional Programming in JavaScript
- 秒懂設計模式
- Android開發:從0到1 (清華開發者書庫)
- 小型編譯器設計實踐
- Visual Basic程序設計習題與上機實踐
- 微信小程序開發實戰:設計·運營·變現(圖解案例版)
- Simulation for Data Science with R
- Appcelerator Titanium:Patterns and Best Practices
- R的極客理想:量化投資篇
- INSTANT Premium Drupal Themes
- RESTful Web API Design with Node.js(Second Edition)
- Pandas 1.x Cookbook
- C++從零開始學(視頻教學版)(第2版)