Omnifood Project - Optimizations Flashcards
What to do to make the nav bar invisible when it size is mobile (step 1-3)?
.main-nav { background-color: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(10px); position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transform: translateX(100%); display: flex; align-items: center; justify-content: center; transition: all 0.5s ease-in; /* 1) Hide it visually */ /* 2) Make it unaccessible to mouse and keyboard */ /* 3) Hide it from screen readers */
/* 1) Hide it visually */ opacity: 0; /* 2) Make it unaccessible to mouse and keyboard */ pointer-events: none; /* 3) Hide it from screen readers */ visibility: hidden;
In the following example the .nav-open is set on the header instead of the nav element (child of header). Why is that?
const btnNavEl = document.querySelector(".btn-mobile-nav"); const headerEl = document.querySelector(".header"); btnNavEl.addEventListener("click", function () { headerEl.classList.toggle("nav-open"); });
Putting the class on the parent element isn’t required, but is a common practice
How to reach both buttons while they have the same class name?
<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>
Use descended selectors:
.nav-open .icon-mobile-nav[name="close-outline"] { } .nav-open .icon-mobile-nav[name="menu-outline"] { }
When the nav bar is opened, the icon should become a close button. How is this done?
<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>
.nav-open .icon-mobile-nav[name="close-outline"] { display: block; } .nav-open .icon-mobile-nav[name="menu-outline"] { display: none; }
What to do with the button so it always stays on top:
.btn-mobile-nav { display: block; }
.btn-mobile-nav { display: block; z-index: 9999; }
Use the z-index
Where will this link take you?
<header class="header"> <a href="#"> <img class="logo" alt="Omnifood logo" src="img/omnifood-logo.png" /> </a>
This will simply lead to the top of the page
What to fill in here to scroll to the section underneath:
section class="section-cta" > <div class="container">
And button:
~~~
<a>Start eating well</a>
~~~
section class="section-cta" id="cta"> <div class="container">
<a href="#cta" class="btn btn--full margin-right-sm" >Start eating well</a >
So fill in the id in the section and use it in the href
Which method can you use to blur out the background? Are there exception in browsers?
backdrop-filter: blur(10px);
Safari, firefox
How could you tell the html that by default you want a scrollbar in case of overflow and that the scrolling must be smoothly.
html { font-size: 62.5%; }
html { font-size: 62.5%; overflow-x: hidden; scroll-behavior: smooth; }
However this does NOT work on Safari
Where can you test whether design tools are available for web browsers?
caniuse.com
How would you do a backdrop in Safari?
Add the -webkit- prefix to the backdrop filter
.main-nav { background-color: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: blur(5px);
How would you do a backdrop in Firefox?
As a resolution increase the alpha channel of the background-color
So that is looks acceptable in firefox as well
Is it possible to write two of the same media queries?
Yes, no problem at all. Happens a lot actually.
What is Lighthouse used for? Can you use it with Chrome?
Used for adding some improvements to the website
Created by Google so available in the Inspect menu
What test results will Lighthouse give you?
Performance (note that you are loading from your own computer)
Accessibility
Best practices
SEO