You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.2 KiB
2.2 KiB
CSS - Responsive Design
Lesson Objectives
- Explain responsiveness and why we need it
- Describe fluid layout
- Describe the "mobile first" development process
- Explain min/max-height/width
- Define media queries and why we need them
Explain responsiveness
The Backstory
The Phone/Tablet/Phablet wars. Apple, Google, Samsung and a bunch of other companies all released a bunch of devices, all with various dimensions.
Initially, we would test to determine which device was viewing the site, and then serve up different content based on that. This was called adaptive.
Now
Soon there were too many devices to examine and too much different code to write, so we decided to serve the same content to all devices, but modify it slightly so that it still looks good. This is called responsive.
In responsive, the content responds to device attributes
- width
- height
- orientation
- media
Methods to achieve this
- fluid layout
- mobile first
- min/max-height-width
- media queries
Describe Fluid Layout
Layout using percentages so that content shrinks and expands with window dimensions
Describe the "mobile first" development process
- Term is mostly used for designers
- Also applies to developers
- start by developing mobile and move upward
- don't go desktop to mobile
Explain min/max-height/width
- max-width/height
- min-width/height
- EXAMPLE nav when squished
- keep item text on one line
- combine min-width with percentage
- EXAMPLE nav when squished
Define media queries and why we need them
media query possibilites
- http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
- media types
- screen
- tv
- media features
- min-width
- max-width
- min-height
- max-height
- orientation
- resolution
Use mobile-first ideology with media queries
Start with mobile device design and then add media queries for larger screens
- mobile devices typically slower
- will read mobile css and discard larger device css
- larger devices will read mobile data and overwrite
- this is okay since they're faster
- could also have media queries for small devices too
- fine, but can get complex with lots of media queries
- can scan and assume existing queries are only for large devices