Omnifood Project – Responsive Web Design Flashcards
What will happen in case of conflicing CSS with respect to responsive design?
The last bit of CSS will apply:
@media (max-width: 1200px) {
Will check display until 1200px
And then 800px.
Etc..
How to simulate different devices?
Inspect menu, pick devices to simulate
For testing, use the responsive option, then you can drag the window
What is the best method of determining breakpoints?
Drag the screen and wait til it breaks
Whenever design starts to break, a break point is inserted
Which meta tag is absolutely crucial for responsive web design?
<meta></meta>
Scale is initially 100%
It will make so the page meets the screen width
Why not use pixels in responsive design?
Reason is that using pixels will not adjust to the user’s font size settings in the browser
Also not to the user’s zoom level
Therefore setting font-sizs to percentage and NOT to pixels
What file to add for the queries? And how to attach it to HTML?
Add a new CSS file and name it queries.css
Add the HTML a new line:
<link></link>
<link></link>
<link></link>
What about font size in media queries
rem and em do NOT depend on html font-size in media queries!
Instead, 1rem = 1em = 16px
Process of determining max width:
- Determine screen size in pixels
- Divide by 16 (1 rem is 16px)
- Round of (in this case 84 rem)
@media (max-width: 84em) {
.hero {
Also remember:
html {
/* font-size: 10px; /
/ 10px / 16px = 0.625 = 62.5% /
/ Percentage of user’s browser font-size setting */
font-size: 62.5%;
}
Best practise regarding amount of media queries?
It is not a good practise to add 10+ media queries to fix every single problem
So you have a gallery of 3 columns and you want to make it 2. What would you do given below 1344px?
@media (max-width: 84em) {
.hero {
max-width: 120rem;
}
.gallery {
grid-template-columns: repeat(2, 1fr);
}
}
Notice the repeat function that will just repeat the pattern
What are prerequisites for responsive web design?
Fluid grid
responsive images
responsive units (rem)
In responsive design, what to do with the font-size?
Scale it down.
- Determine pixel size, i.e. 8px
- Then do 8px / 16px = 0.5
- The font-size decreases then to 50%
@media (max-width: 75em) {
html {
/* 8px / 16px */
font-size: 50%;
}
How to turn the hero simply into 1 column?
.hero {
max-width: 130rem;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr;
align-items: center;
}
.hero {
grid-template-columns: 1fr;
}
A very good practise when tweaking sections?
Hold the css style file next to the queries file for extra ease
Where in the HTML doc should you add the mobile buttons?
Add it in the header section just before closing