Omnifood Project - Setup and Desktop Version Flashcards
What is a good way to start a new front end project?
Make and MD document in VS code where you put all the text divided over sections
In general CSS file, add al the font sizes, line heights, spacing distances, color combinations, generic blocks, etc
What elements are by default needed in your MD file?
Font sizes / weights
Line heights
Spacing system
Typography system
Shadows
Border radii
White space
What are the four responsive design ingredients?
Fluid Layouts
Responsive Units
Flexible Images
Media Queries
What are the tips / reminders for fluid layouts?
To allow the webpage to adapt to the current viewport width
Use % (or vh / vw) unit instead of px for elements that should adapt to viewport (usually layout)
Use max-width instead of width
Flexbox and CSS grid are fluid by default
What are the tips / reminders for Responsive Units?
Use rem unit instead of px for most lengths
This will make it easy to scale the entire layout down automatically
Helpful trick: Setting 1rem to 10px for easy calculations
What are the tips / reminders for Flexible Images?
By default, images don’t scale automatically as we change the viewport. so we need to fix that
Always use % for image dimensions, together with the max-width property
What are the tips / reminders for Media Queries?
Change CSS styles on certain viewport widths
What are the downsides of setting an element with:
width: 1000px;
How to resolve?
The viewport will show a scroll bar because the element remains 1000px
Therefore use:
max-width: 1000px;
What are the downsides of setting an element with:
width: 100%;
How to resolve?
When the element is 1000px and the screen is wider than 1000px, the element will feature the whole viewport width and that is not what you want.
Therefore use:
max-width: 1000px;
What does rem stand for and how large is it by default?
Root element
By default it is 16px
What does rem size depend on?
Font size
Herein lies the strength of rem - When changing the font size all lengths are automatically updated based on that change
How would you set the rem to 10 instead of 16?
html{
font-size: 10px;
}
This is very convenient because it makes it easy to calculate with
What is recommended instead of setting the font-size to 10?
font-size: 62.5%
This is because 62.5% of 16px is 10px
html{
font-size: 62.5%;
}
It is recommended to not use pixels for font-size
How to easily center something on a page (again) ?
Use the margin trick as shown below:
.hero {
max-width: 130rem;
margin: 0 auto;
What is a great tool to use to generate tints towards black and tints towards white?
https://maketintsandshades.com/
It is bookmarked.
Hence the following buttons:
<a>Start eating well</a>
<a>Learn more ↓</a>
How to address both buttons and how to address a single one?
Both:
.btn,
.btn:link,
.btn:visited {
display: inline-block;
Single:
.btn–full:link,
.btn–full:visited {
background-color: #e67e22;
color: #fff;
}
.btn–outline:link,
.btn–outline:visited {
background-color: #fff;
color: #555;
}
What trick can you apply when there’s a border around a button?
Use box-shadow instead of border:
.btn–outline:active {
/* border: 3px solid #fff; /
/ Trick to add border inside */
box-shadow: inset 0 0 0 3px #fff;
}
How to add a bit of animation to a button?
Use the transition property
.link:visited {
transition: all 0.3s;
}
What is a helper class?
Adding an extra name to the class so you can refer to that specific html part
How to add new fonts? What will you receive?
You will receive a set of link elements
These need to be placed between you meta and title tags
When to use flexbox over grid?
Small designs
Align elements: Create a flex container using display: flex and then define the flex-direction that you want
How to make images in a row overlap a little bit? And how to make sure the last one does not?
Use margin right
.delivered-imgs {
display: flex;
}
.delivered-imgs img {
height: 4.8rem;
width: 4.8rem;
border-radius: 50%;
margin-right: -1.6rem;
border: 3px solid #fdf2e9;
}
.delivered-imgs img:last-child {
margin: 0;
}
When a span element is part of a p element and you want to change the span styling. What to do?
Use a descended selector instead of a new class
.delivered-text span {
color: #cf711f;
font-weight: 700;
}
What is a useful tool to check color contrast?
coolors.co
And then contrast checker
What does the nav element do?
Nothing, but is very useful semantically
What is the main element used for?
Contains the main area of the web document, so without header and footer
What could be a good reason for not giving the header padding? Does this apply to height or width?
You might want to make it sticky later on. Applies to height. Not to width
How is a nav section tyoically set up in HTML?
Nav tag, ul tag, list tags with link tags
Then it is modified later on
How to get rid of the bullet points in a list
list-style: none;
What element should a button in the nav bar become when you want to apply a bit of padding?
inline-block;
Say you want to style the last button in the nav bar differently. What would you do?
How do you make sure this one applies and not the other one?
Create a new class for the last button
The more specific the class, the higher precedence it has
What is a good trick for copying a line beneath the current line?
Shift + Alt + Arrow
.section-how:nth-child(1){}
Somehow this does not work. Why?
You have to use a descended selector here:
.section-how div:nth-child(1){}
How could this be written as well?
grid-template-columns: repeat(2, 1fr)
grid-template-columns: repeat(1fr, 1fr)
Given:
<section>
<div class="container"
<div>Test 1</div>
<div>Test 2</div>
How to style the Test elements
</section>
Use double div
.section-how div div {
}
When same CSS applies to two classes, how to write this in CSS?
.heading-primary,
.heading secondary{
}
Color coding: How to easily play with white/grey values?
Go from #fff to #eee to #ddd and check results
How to quickly center an image in the container?
Set container to flex, then center with align-items and justify-content
You want to apply a pseudo element to an image. How to?
Pseudo element cannot be applied to an image. It is not allowed to attach child elements to images.
Therefore apply it to the container of that image.
How to add a circle behind an image?
Set the container element of the image to relative
Set the pseudo element to absolute and make sure it is a block element
step-img-box::before{}
Use the z-index and put it to -1 to set it to the background
How to add two concentric circles behind an image?
Use the code for 1 circle
You can’t use ::before another time, therefore use ::after
Play with the z-index to place the circles accordingly
When using
step-img-box::before{}
as a pseudo element, it sometimes does not take the height: 60% property from the parent. How to resolve?
Set padding-bottom:60%
This should work
What is the use of h2 here?
<h2>As featured in</h2>
None. It is pure sementically. The class determines the styling.
Difference between space-between and space-around in flexbox?
Space between does not apply to spacing of the left side of the first element and the right side of the last element
How to set colored items to a gray scale? What problem could then still be there?
filter: grayscale(100%)
There fill be different gray tones, also black