s2 - Learning - Css Box Model & Units - For Student
s2 - Learning - Css Box Model & Units - For Student
BOX MODEL
UNITS
E1 E1 E2 E3
E2
E3
EXPLAIN
<main> <i>
<section> <img>
<table> <input>
<nav> <q>
<ul>
<ol>
<li>
EXPLAIN
Change the Display property
You can change an element's display type using the display attribute
<ul> li { li {
<li>HOME display: block display: inline
<li>NEWS } }
<li>HELP
</ul> HOME
NEWS
HOME NEWS HELP
HELP
1 2
Which diagram refers to paddings?
1 2
ACTIVITY
10 MIN
Activity 1
Look at the provided code and evaluate the margins, paddings and border of elements
1 - TOP
TOP RIGHT BOTTOM LEFT
p {
margin: 20px 30px 40px 50px ;
}
4 - LEFT 2 - RIGHT 20
30
50
3 - BOTTOM 40
ACTIVITY
10 MIN
Activity 2
Create 3 Boxes following given constraints:
CONSTRAINTS
• Divs width and height : 200px
• Divs Background color : follow mockup
• Divs shall be displayed corner to corner
Compute the total width and height, given the above code
QUIZ
content-box border-box
(default value)
200 px
260 px
140 px
200 px
width: 200px;
width: 200px;
padding: 20px;
padding: 20px;
border: 10px;
border: 10px;
box-sizing: border-box;
box-sizing: content-box;
• Total width = 260px (200px + 20px + 20px + 10px + 10px) • Total width = 200px
• Content width = 200px • Content width = 140px (200px - 20px - 20px - 10px - 10px)
EXPLAIN
CSS Units
Percentage based Font based Viewport based
EXPLAIN
50 %
EXPLAIN
Font based units
rem unit em unit
The length is relative to the The length is relative to the
root element font size parent element font size
EXPLAIN
div {
height: 100vh
}
100vh is equal to 100% of the height of the viewport
div {
width: 50vw
}
50 vw is equal to 50% of the width of the viewport
RESEARCH
Research Assessment
Before session C3-S4, make researches regarding the bellow topics:
Expected outcome
- Different uses cases where each unit is more appropriate
- Illustration of each case with some code
Tips
- Consider accessibility, multiple device, responsivity etc.…
Congratulations !
You should now master those concepts
BOX MODEL
UNITS
3-2-1 Challenge
✓ List three things you learned today.
✓ List two questions you still have.
✓ List one aspect of the lesson or topic you enjoyed.
TODO AFTER