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
Also take into account common screen width ranges
Which meta tag is absolutely crucial for responsive web design?
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Scale is initially 100%
It will make it so the page will match the screen’s width
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 rel="stylesheet" href="css/general.css" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/queries.css" />
What is a particularity about responsive units (rem / em) in media queries?
They do NOT respond to the font-size setting (62,5%) in the HTML
In media queries 1 rem is NOT 10 pixels
Instead 1 rem will ALWAYS be the default size browser setting (16px)
1 rem = 1 em = 16px
rem is root font size
em is the current font size
rem used to have some bugs in media queries, but might be solved now.
Process of determining max width:
- Determine screen size breaking point in pixels, in this case around 1350px (smaller desktops)
- Divide by 16 (1 rem is 16px)
- Round of (in this case 84 rem)
@media (max-width: 84em) {
Why is there em and rem used in these cases
@media (max-width: 84em) {
.hero {
max-width: 120rem;
}
}
em is used in the media query only. It has nothing to do with the rem as applied to the hero class. That rem is similar to the rem used apart from the responsive design.
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 (.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 { ? } }
@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 is great trick to scale everything down AT ONCE?
Scale down the font-size:
- Determine pixel size, i.e. 8px
- Then do 8px / 16px = 0.5
- The font-size decreases then to 50%
(before it was 62,5%)
Example:
~~~
@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 after the other nav element:
<nav class="main-nav"> <ul class="main-nav-list"> <li><a class="main-nav-link" href="#">How it works</a></li> <li><a class="main-nav-link" href="#">Meals</a></li> <li><a class="main-nav-link" href="#">Testimonials</a></li> <li><a class="main-nav-link" href="#">Pricing</a></li> <li><a class="main-nav-link nav-cta" href="#">Try for free</a></li> </ul> </nav> <button class="btn-mobile-nav"> <ion-icon class="icon-mobile-nav" name="menu-outline"></ion-icon> <ion-icon class="icon-mobile-nav" name="close-outline"></ion-icon> </button> </header>