Accessibility
Accessibility
Introduction to Accessibility
When designing a website, it is important to keep in mind that some users access the Internet in
many different ways. For example, many users with a visual impairment use screen readers to
access content on the Internet.
A screen reader is a piece of software that provides an audio description of a web page’s content.
A screen reader not only reads the visual content out loud, it also reads out element names and
other attributes that make it easier for visually impaired users to navigate a web page.
In the early days of the Internet, many pages were saturated with graphics and flash animations.
Screen readers, unfortunately, could not interpret these types of elements. As such, a person with
a visual impairment might not have been able to perceive important information on a website.
For this reason, the Web Accessibility Initiative (led by W3C) developed standards for making
information on the Internet accessible to all.
These standards fall under a group of guidelines called ARIA, or Accessible Rich Internet
Applications. These guidelines are easily implemented and make web pages accessible to a
broader audience. We’ll learn how to use ARIA roles and properties in this lesson to improve
access for people who are visually impaired.
1. Semantic Elements
2. ARIA Roles
3. ARIA Properties
4. alt Attributes
Instructions
<html>
<head>
</head>
<body>
<header>
<h1>PROGRAMMING</h1>
</header>
<nav>
<ul role="presentation">
<li><a href="#early">Early</a></li>
<li><a href="#middle">Middle</a></li>
<li><a href="#late">Late</a></li>
<li><a href="#current">Current</a></li>
</ul>
</nav>
<div id="early" class="container">
<span class="aside" role="note">Ada Lovelace is the favorite programmer of the author of this web
page!</span>
<h2>Early</h2>
<h4>Pre-1900</h4>
<p>Below is an image of Ada Lovelace, born in 1815 (<em>Died: 1852</em>). She worked with
Charles Babbage and is known as the first programmer.</p>
</div>
<img src="
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-babbage.jpg"
alt="Charles Babbage"/>
</div>
</div>
</div>
</div>
<h2>Middle</h2>
<h4>1900-1980</h4>
<p>Below is an image of Grace Hopper, born in 1906 (<em>Died: 1992</em>). She invented the first
compiler and contributed to the COBOL language.</p>
<p>Below is an image of Dennis Ritchie, born in 1941 (<em>Died: 2011</em>). He created the C
programming language (1972) and helped develop Unix.</p>
</div>
</div>
</div>
</div>
</div>
<h2>Late</h2>
<h4>1980 - 2000</h4>
<p>Below is an image of Guido Van Rossum, born in 1956. He helped to create the Python language
in 1991.</p>
<p>Below is an image of Yukihiro Matsumoto, born in 1965. He developed Ruby, which was first
available in 1995.</p>
</div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-vanrossum.jpg"
alt="Guido Van Rossum"/>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-matusmoto.jpg"
alt="Yukihiro Matsumoto"/>
</div>
</div>
</div>
</div>
<h2>Current</h2>
<h4>2000 - Present</h4>
<p>Below is an image of Robert Griesemer. He was on the Google team that developed GOLANG,
which first appeared in 2009.</p>
<p>Below is an image of Chris Lattner, a developer at Apple. He helped to write Swift, which first
appeared in 2014.</p>
</div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-griesemer.jpg"
alt="Robert Griesemer"/>
</div>
</div>
</div>
</div>
<footer>
<ul role="presentation">
<li>[email protected]</li>
</ul>
</footer>
</body>
</html>
header {
background-color: #0e0e0e;
color: white;
padding: 5px;
position: fixed;
width: 100%;
z-index: 2;
nav {
text-align: right;
margin-bottom: 10px;
position: fixed;
top: 87px;
width: 100%;
z-index: 2;
nav li {
display: inline-block;
width: 60px;
padding: 5px;
text-align: center;
}
nav a {
text-decoration: none;
color: white;
p{
color: white;
height: 200px;
width: 200px;
display: inline-block;
footer {
height: 100px;
color: white;
position: relative;
top: 150px;
footer li {
display: inline;
.container {
text-align: center;
max-width: 980px;
min-width: 625px;
position: relative;
top: 120px;
padding-top: 120px;
.date-square {
width: 55px;
height: 50px;
background-color: white;
position: relative;
bottom: 25px;
display: inline-block;
z-index: 1;
.date-square p {
color: black;
width: 50px;
height: 30px;
background-color: white;
text-align: center;
margin: 0;
position: relative;
top: 10px;
#logo {
height: 100px;
width: auto;
margin: 0px;
position: absolute;
right: 5px;
bottom: 5px;
}
ACCESSIBILITY
Semantic HTML Elements
The quickest way of improving accessibility for screen readers is to use the
appropriate tags for a given task.
<div id="header">
<!-- Header Elements -->
</div>
In the example above, header content is wrapped in a div tag with the
ID header. While this is valid HTML, an individual using a screen reader will not
understand the purpose of the div is and, instead, will have to piece the web
page together as child elements are read out loud to them.
<header>
<!--Header Elements-->
</header>
In the example above, the HTML will render the same exact content present in
the first example. However, this example uses the correct semantic element
(<header>), which allows an individual using a screen reader to easily identify
the purpose of the elements inside of the header.
Instructions
1.
The header of this website is wrapped in a div with the id header.
In index.html, remove this div and wrap this section with opening and
closing <header> tags instead.
Checkpoint 2 Passed
2.
The CSS no longer functions correctly because we changed the name of the
element.
3.
The navigation of this website is wrapped in a div with the id nav.
In index.html, remove this div and wrap this section with opening and
closing <nav> tags instead.
Checkpoint 4 Passed
4.
Once again, we’ll have to update the CSS stylesheet since we modified the
HTML.
5.
The footer of this website is wrapped in a div with the id footer. In index.html,
remove this div and wrap this section with opening and closing <footer> tags
instead.
Checkpoint 6 Passed
6.
Let’s update the CSS stylesheet one more time.
header {
background-color: #0e0e0e;
color: white;
padding: 5px;
position: fixed;
width: 100%;
z-index: 2;
}
nav {
text-align: right;
margin-bottom: 10px;
position: fixed;
top: 87px;
width: 100%;
z-index: 2;
nav li {
display: inline-block;
width: 60px;
padding: 5px;
text-align: center;
nav a {
text-decoration: none;
color: white;
p{
color: white;
height: 200px;
width: 200px;
display: inline-block;
footer {
height: 100px;
color: white;
position: relative;
top: 150px;
footer li {
display: inline;
.container {
text-align: center;
max-width: 980px;
min-width: 625px;
position: relative;
top: 120px;
padding-top: 120px;
.date-square {
width: 55px;
height: 50px;
background-color: white;
position: relative;
bottom: 25px;
display: inline-block;
z-index: 1;
.date-square p {
color: black;
width: 50px;
height: 30px;
background-color: white;
text-align: center;
margin: 0;
position: relative;
top: 10px;
#logo {
height: 100px;
width: auto;
margin: 0px;
position: absolute;
right: 5px;
bottom: 5px;
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h1>PROGRAMMING</h1>
</header>
<nav>
<ul>
<li><a href="#early">Early</a></li>
<li><a href="#middle">Middle</a></li>
<li><a href="#late">Late</a></li>
<li><a href="#current">Current</a></li>
</ul>
</nav>
<span class="aside">Ada Lovelace is the favorite programmer of the author of this web page!</span>
<div class="topline"></div>
<h2>Early</h2>
<h4>Pre-1900</h4>
<div class="p-container">
<p>Below is an image of Ada Lovelace, born in 1815 (<em>Died: 1852</em>). She worked with
Charles Babbage and is known as the first programmer.</p>
</div>
<img src="
https://content.codecademy.com/courses/freelance-1/unit-4/img-lovelace.jpg" />
<div class="timeline">
<div class="date-square">
<p>1840</p>
</div>
<div class="date-square">
<p>1850</p>
</div>
</div>
</div>
<div class="topline"></div>
<h2>Middle</h2>
<h4>1900-1980</h4>
<div class="p-container">
<p>Below is an image of Grace Hopper, born in 1906 (<em>Died: 1992</em>). She invented the first
compiler and contributed to the COBOL language.</p>
<p>Below is an image of Dennis Ritchie, born in 1941 (<em>Died: 2011</em>). He created the C
programming language (1972) and helped develop Unix.</p>
</div>
<div class="timeline">
<div class="date-square">
<p>1950</p>
</div>
<div class="date-square">
<p>1978</p>
</div>
</div>
</div>
<div class="topline"></div>
<h2>Late</h2>
<h4>1980 - 2000</h4>
<div class="p-container">
<p>Below is an image of Guido Van Rossum, born in 1956. He helped to create the Python language
in 1991.</p>
<p>Below is an image of Yukihiro Matsumoto, born in 1965. He developed Ruby, which was first
available in 1995.</p>
</div>
<div class="timeline">
<div class="date-square">
<p>1991</p>
</div>
<div class="date-square">
<p>1995</p>
</div>
</div>
</div>
<div id="current" class="container">
<div class="topline"></div>
<h2>Current</h2>
<h4>2000 - Present</h4>
<div class="p-container">
<p>Below is an image of Robert Griesemer. He was on the Google team that developed GOLANG,
which first appeared in 2009.</p>
<p>Below is an image of Chris Lattner, a developer at Apple. He helped to write Swift, which first
appeared in 2014.</p>
</div>
<div class="timeline">
<div class="date-square">
<p>2010</p>
</div>
<div class="date-square">
<p>2014</p>
</div>
</div>
</div>
<footer>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-logo2.png" id="logo" />
<ul>
<li>
</li>
<li>
</li>
</ul>
</footer>
</body>
</html>
ACCESSIBILITY
ARIA Properties
ARIA properties are attributes that you can add to HTML elements. These
attributes provide additional information about elements that might not be
obvious to users of screen readers. Let’s explore a property called aria-label.
Other ARIA properties are useful in more complex websites using HTML forms,
JavaScript, and other advanced tools.
ARIA Techniques
Instructions
1.
In the <p> tag containing 1840, add an aria-label attribute that says Date of
Lovelace photo.
Checkpoint 2 Passed
2.
In the <p> tag containing 1850, add an aria-label attribute that says Date of
Babbage photo. We will add the appropriate aria-label to the rest of the
squares containing the dates of the images for you.
ACCESSIBILITY
Alt Attribute
Some HTML elements have a built-in attribute called alt that works like aria-
label but has additional functionality.
Instructions
1.
Give the logo an alt attribute with the value company logo. This element can be
found in the footer of index.html.
Checkpoint 2 Passed
2.
Give the image of Ada Lovelace an alt attribute with the value Ada Lovelace.
Checkpoint 3 Passed
3.
Give the image of Charles Babbage an alt attribute with the value Charles
Babbage. We will add the rest of the alt tags for you
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h1>PROGRAMMING</h1>
</header>
<nav>
<ul role="presentation">
<li><a href="#early">Early</a></li>
<li><a href="#middle">Middle</a></li>
<li><a href="#late">Late</a></li>
<li><a href="#current">Current</a></li>
</ul>
</nav>
<div id="early" class="container">
<span class="aside" role="note">Ada Lovelace is the favorite programmer of the author of this web
page!</span>
<h2>Early</h2>
<h4>Pre-1900</h4>
<p>Below is an image of Ada Lovelace, born in 1815 (<em>Died: 1852</em>). She worked with
Charles Babbage and is known as the first programmer.</p>
</div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-babbage.jpg"
</div>
</div>
</div>
</div>
<h2>Middle</h2>
<h4>1900-1980</h4>
<p>Below is an image of Grace Hopper, born in 1906 (<em>Died: 1992</em>). She invented the first
compiler and contributed to the COBOL language.</p>
<p>Below is an image of Dennis Ritchie, born in 1941 (<em>Died: 2011</em>). He created the C
programming language (1972) and helped develop Unix.</p>
</div>
</div>
</div>
</div>
</div>
<div id="late" class="container">
<h2>Late</h2>
<h4>1980 - 2000</h4>
<p>Below is an image of Guido Van Rossum, born in 1956. He helped to create the Python language
in 1991.</p>
<p>Below is an image of Yukihiro Matsumoto, born in 1965. He developed Ruby, which was first
available in 1995.</p>
</div>
</div>
</div>
</div>
</div>
<div id="current" class="container">
<h2>Current</h2>
<h4>2000 - Present</h4>
<p>Below is an image of Robert Griesemer. He was on the Google team that developed GOLANG,
which first appeared in 2009.</p>
<p>Below is an image of Chris Lattner, a developer at Apple. He helped to write Swift, which first
appeared in 2014.</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<img src="https://content.codecademy.com/courses/freelance-1/unit-4/img-logo2.png" id="logo"
alt="company logo" />
<ul role="presentation">
<li>[email protected]</li>
</ul>
</footer>
</body>
</html>
ACCESSIBILITY
Review: Accessibility
Using ARIA roles and properties, alt attributes, and semantic elements in your HTML is a
simple way to make your website accessible to visually-impaired Internet users.
In this lesson, you will learn how to look up new ways to use previously-learned CSS
properties and discover entirely new CSS properties.
On the right side of the screen is the portfolio site that you will develop into the final
product. We suggest you keep this mock open in a separate tab for reference
throughout the lesson.
nav {
padding: 25px;
background-color: #F25F5C;
h1 {
float: left;
margin-top: 5px;
color: white;
font-size: 36px;
ul {
float: right;
li {
display: inline-block;
margin-right: 25px;
text-align: center;
background-color: #28587B;
}
a{
display: inline-block;
width: 150px;
padding: 10px 0;
text-decoration: none;
font-size: 24px;
color: white;
.clearfix:after {
visibility: hidden;
display: block;
height: 0;
clear: both;
h1 {
display: none;
li {
margin-right: 10px;
}
a{
width: 100px;
padding: 5px 0;
font-size: 16px;
}
nav {
padding: 25px;
background-color: #F25F5C;
h1 {
float: left;
margin-top: 5px;
color: white;
font-size: 36px;
ul {
float: right;
li {
display: inline-block;
margin-right: 25px;
text-align: center;
background-color: #28587B;
a{
display: inline-block;
width: 150px;
padding: 10px 0;
text-decoration: none;
font-size: 24px;
color: white;
.clearfix:after {
visibility: hidden;
display: block;
height: 0;
clear: both;
h1 {
display: none;
li {
margin-right: 10px;
}
a{
width: 100px;
padding: 5px 0;
font-size: 16px;
For example, if you want to know how to change the size of text, you could
google “how to change text size using CSS.” After doing this, you will receive
multiple links to information about the font-size property.
Instructions
1.
In the mock, we can see that the a elements should have a light shadow
beneath them. Use Google to find out which CSS property allows you to add a
shadow beneath text. Once you’ve found the property, set its value to 2px 2px
0 #bbbbbb in the a rule (try to figure out what this value will do by reading the
documentation for the property).
DOCUMENTATION AND RESEARCH
Google
Documentation is an essential tool to learn about properties. However, what if
you don’t even know what property you need?
For example, if you want to know how to change the size of text, you could
google “how to change text size using CSS.” After doing this, you will receive
multiple links to information about the font-size property.
Instructions
1.
In the mock, we can see that the a elements should have a light shadow
beneath them. Use Google to find out which CSS property allows you to add a
shadow beneath text. Once you’ve found the property, set its value to 2px 2px
0 #bbbbbb in the a rule (try to figure out what this value will do by reading the
documentation for the property).
DOCUMENTATION AND RESEARCH
Google
Documentation is an essential tool to learn about properties. However, what if
you don’t even know what property you need?
For example, if you want to know how to change the size of text, you could
google “how to change text size using CSS.” After doing this, you will receive
multiple links to information about the font-size property.
Instructions
1.
In the mock, we can see that the a elements should have a light shadow
beneath them. Use Google to find out which CSS property allows you to add a
shadow beneath text. Once you’ve found the property, set its value to 2px 2px
0 #bbbbbb in the a rule (try to figure out what this value will do by reading the
documentation for the property).
nav {
padding: 25px;
background-color: #F25F5C;
h1 {
float: left;
margin-top: 5px;
color: white;
font-size: 36px;
ul {
float: right;
li {
display: inline-block;
margin-right: 25px;
text-align: center;
background-color: #28587B;
border-radius: 5px;
}
a{
display: inline-block;
width: 150px;
padding: 10px 0;
text-decoration: none;
font-size: 24px;
color: white;
.clearfix:after {
visibility: hidden;
display: block;
height: 0;
clear: both;
h1 {
display: none;
li {
margin-right: 10px;
}
a{
width: 100px;
padding: 5px 0;
font-size: 16px;
In summary:
margin: 0;
padding: 0;
img {
height: auto;
width: auto;
ul {
text-align: right;
h1 {
font-size: 20px;
/*Sizing*/
.container {
margin: 0 auto;
}
.spacer {
max-width: 1200px;
margin: auto;
.main {
background-color: #ffc200;
/*Header Section*/
.header {
margin-left: 50px;
margin-right: 50px;
.header li {
list-style: none;
display: inline-block;
.header li a {
color: #333;
margin:0;
border:0px;
}
/*Jumbotron Section*/
.jumbotron {
background-color: #fff;
max-width: 1200px;
margin-left: 50px;
.jumbotron h2 {
font-size: 50px;
margin-bottom: 70px;
.jumbotron h2 span {
color:#ffc200;
.jumbotron p {
text-shadow: 0 0;
font-size: 16px;
color: #666;
margin-bottom: 0;
}
/*Banner Section*/
.banner {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
/*Expertise Section*/
.cards {
background-color: #ffc200;
display: flex;
justify-content: space-around;
flex-wrap: wrap;
.col {
display: inline-flex;
flex-direction: column;
justify-content: space-between;
#expertise {
padding: 20px;
background-color: #ffc200;
margin: 0;
text-align: center;
/*Footer Section*/
.footer {
background-color: #000;
color: #fff;
.footer h3 {
font-size: 20px;
margin-left: 20px;
.footer p {
font-size:12px;
margin-bottom: 0;
margin-left: 20px;
}
<!doctype html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic'
rel='stylesheet'>
</head>
<body>
<div class='header'>
<div class='container'>
<h1>Headlines.</h1>
<ul>
<li><a href='3'>About</a></li>
</ul>
</div>
</div>
<div class='jumbotron'>
<div class='container'>
</div>
</div>
<div class='banner'>
<div class='container'>
</div>
</div>
<div class='container'>
<div class='main'>
<div class='spacer'>
<div class='cards'>
<div class='col'>
<img src='https://content.codecademy.com/projects/headlines/p1.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p6.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p8.jpg'>
</div>
<div class='col'>
<img src='https://content.codecademy.com/projects/headlines/p2.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p5.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p7.jpg'>
</div>
<div class='col'>
<img src='https://content.codecademy.com/projects/headlines/p3.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p4.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p9.jpg'>
<img src='https://content.codecademy.com/projects/headlines/p10.jpg'>
</div>
</div>
</div>
</div>
</div>
<div class='footer'>
<h3>Headlines.</h3>
</div>
</body>
</html>
FLEXBOX
display: flex
Any element can be a flex container. Flex containers are helpful tools for
creating websites that respond to changes in screen sizes. Child elements of
flex containers will change size and location in response to the size and
position of their parent container.
div.container {
display: flex;
}
In the example above, all divs with the class container are flex containers. If
they have children, the children are flex items. A div with the
declaration display: flex; will remain block level — no other elements will
appear on the same line as it.
However, it will change the behavior of its child elements. Child elements will
not begin on new lines. In the exercises that follow, we will cover how the
flex display property impacts the positioning of child elements.
Instructions
1.
In the <div> with id flex, add a display property with a value of flex. Compare
the two divs in the browser.
Checkpoint 2 Passed
Hint
Inside the curly braces of the #flex selector ruleset, the display property
should have a value of flex
selector {
property: value;
}
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
text-align: center;
h2 {
font-size: 16px;
text-align: center;
.container {
background-color: whitesmoke;
.box {
background-color: dodgerblue;
height: 100px;
width: 100px;
}
#flex {
display:flex;
}
<!DOCTYPE html>
<html>
<head>
<title>Inline</title>
</head>
<body>
<h1>Inline-flex</h1>
<div class='container'>
<div class='box'>
<h3>1</h3>
</div>
<div class='box'>
<h3>2</h3>
</div>
<div class='box'>
<h3>3</h3>
</div>
</div>
<div class='container'>
<div class='box'>
<h3>1</h3>
</div>
<div class='box'>
<h3>2</h3>
</div>
<div class='box'>
<h3>3</h3>
</div>
</div>
</body>
</html>
body {
margin: 0;
border: 0;
text-align: center;
h1 {
font-size: 18px;
text-align: center;
.container {
width: 150px;
border: 1px solid grey;
.box {
background-color: dodgerblue;
height: 75px;
width: 75px;
}
body {
margin: 0;
border: 0;
text-align: center;
h1 {
font-size: 18px;
text-align: center;
.container {
display:inline-flex;
width: 150px;
.box {
background-color: dodgerblue;
height: 75px;
width: 75px;
}
FLEXBOX
justify-content
In previous exercises, when we changed the display value of parent containers
to flex or inline-flex, all of the child elements (flex items) moved toward the
upper left corner of the parent container. This is the default behavior of flex
containers and their children. We can specify how flex items spread out from
left to right, along the main axis. We will learn more about axes in a later
exercise.
.container {
display: flex;
justify-content: flex-end;
}
In the example above, we set the value of justify-content to flex-end. This will
cause all of the flex items to shift to the right side of the flex container.
flex-start — all items will be positioned in order, starting from the left
of the parent container, with no extra space between or before them.
flex-end — all items will be positioned in order, with the last item
starting on the right side of the parent container, with no extra space
between or after them.
center — all items will be positioned in order, in the center of the parent
container with no extra space before, between, or after them.
space-around — items will be positioned with equal space before and
after each item, resulting in double the space between elements.
space-between — items will be positioned with equal space between
them, but no extra space before the first or after the last elements.
In the definitions above, “no extra space” means that margins and borders will
be respected, but no more space (than is specified in the style rule for the
particular element) will be added between elements. The size of each
individual flex item is not changed by this property.
Instructions
1.
Assign the <div> element with the id flexstart a justify-content property with
a value of flex-start.
Stretch and shrink the browser window to compare and contrast how the
elements in each div behave.
Stuck? Get a hint
5.
Assign the <div> element with the id spacebetween a justify-content property
with a value of space-between.
body {
border: 0;
margin: 0;
h1 {
text-align: center;
display: block;
font-size: 18px;
.container {
height: 150px;
width: 100%;
display: flex;
background-color: whitesmoke;
.box {
height: 75px;
width: 100px;
background-color: dodgerblue;
display: inline-block;
#flexstart {
#flexend {
#center {
#spacearound {
#spacebetween {
}
body {
border: 0;
margin: 0;
h1 {
text-align: center;
display: block;
font-size: 18px;
.container {
height: 150px;
width: 100%;
display: flex;
background-color: whitesmoke;
.box {
height: 75px;
width: 100px;
background-color: dodgerblue;
display: inline-block;
}
#flexstart {
justify-content: flex-start;
#flexend {
justify-content: flex-end;
#center {
justify-content: center;
#spacearound {
justify-content: space-around;
#spacebetween {
justify-content: space-between;
<!DOCTYPE html>
<html>
<head>
<title>Flex Justify</title>
</head>
<body>
<h1>Flex Start</h1>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
<h1>Flex End</h1>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
<h1>Center</h1>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
<h1>Space Around</h1>
<div class='container' id='spacearound'>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
<h1>Space Between</h1>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
</body>
</html>
https://www.codecademy.com/learn/paths/learn-how-to-build-websites/tracks/advanced-css-flexbox-
and-animations/modules/layout-with-flexbox/cheatsheet
body {
border: 0;
margin: 0;
h1 {
text-align: center;
display: block;
font-size: 18px;
}
.container {
height: 150px;
width: 100%;
display: flex;
background-color: whitesmoke;
.box {
height: 75px;
width: 100px;
background-color: dodgerblue;
display: inline-block;
#flexstart {
justify-content: flex-start;
#flexend {
justify-content: flex-end;
}
#center {
justify-content: center;
#spacearound {
justify-content: space-around;
#spacebetween {
justify-content: space-between;
}
FLEXBOX
align-items
In the previous exercise, you learned how to justify the content of a flex
container from left to right across the page. It is also possible to align flex
items vertically within the container. The align-items property makes it
possible to space flex items vertically.
.container {
align-items: baseline;
}
In the example above, the align-items property is set to baseline. This means
that the baseline of the content of each item will be aligned.
These five values tell the elements how to behave along the cross axis of the
parent container. In these examples, the cross axis stretches from top to
bottom of the container. We’ll learn more about this in a future exercise.
Instructions
1.
Assign the <div> element with id flexstart an align-items property with the
value flex-start.
Stuck? Get a hint
2.
Assign the <div> element with id flexend an align-items property with the
value flex-end.
Stuck? Get a hint
3.
Assign the <div> element with id center an align-items property with the
value center.
Stuck? Get a hint
4.
Assign the <div> element with id baseline an align-items property with the
value baseline. How does the behavior of these elements differ from those in
other divs?
Stuck? Get a hint
5.
Take a look at the elements under “Stretch” at the bottom of the page. Now,
in the .left, .center, right ruleset, change the height property to min-
height and observe what happens to these elements.
body {
h1 {
margin: 20px;
text-align: center;
font-size: 18px;
.container {
height: 150px;
background-color: whitesmoke;
display: flex;
justify-content: center;
.left,
.center,
.right {
height: 75px;
width: 125px;
background-color: dodgerblue;
#baseline .center {
height: 100px;
width: 100px;
}
#flexstart {
#flexend {
#center {
#baseline {
body {
h1 {
margin: 20px;
text-align: center;
font-size: 18px;
}
.container {
height: 150px;
background-color: whitesmoke;
display: flex;
justify-content: center;
.left,
.center,
.right {
min-height: 75px;
width: 125px;
background-color: dodgerblue;
#baseline .center {
height: 100px;
width: 100px;
#flexstart {
align-items: flex-start;
}
#flexend {
align-items: flex-end;
#center {
align-items: center;
#baseline {
align-items: baseline;
}
FLEXBOX
flex-grow
In Exercise 3, we learned that all flex items shrink proportionally when the flex
container is too small. However, if the parent container is larger than necessary
then the flex items will not stretch by default. The flex-grow property allows us
to specify if items should grow to fill a container and also which items should
grow proportionally more or less than others.
<div class='container'>
<div class='side'>
<h1>I’m on the side of the flex container!</h1>
</div>
<div class='center'>
<h1>I'm in the center of the flex container!</h1>
</div>
<div class='side'>
<h1>I'm on the other side of the flex container!</h1>
</div>
</div>
.container {
display: flex;
}
.side {
width: 100px;
flex-grow: 1;
}
.center {
width: 100px;
flex-grow: 2;
}
In the example above, the .container div has a display value of flex, so its
three child divs will be positioned next to each other. If there is additional
space in the .container div (in this case, if it is wider than 300 pixels), the flex
items will grow to fill it. The .center div will stretch twice as much as
the .side divs. For example, if there were 60 additional pixels of space,
the center div would absorb 30 pixels and the side divs would absorb 15 pixels
each.
If a max-width is set for an element, it will not grow larger than that even if
there is more space for it to absorb.
All of the previous properties we have learned are declared on flex containers,
or the parent elements. This property — flex-grow — is the first we have
learned that is declared on flex items.
Instructions
1.
Assign .top.side and .top.center a flex-grow value of 1. Stretch and shrink the
browser.
Stuck? Get a hint
2.
Assign .middle.center the flex-grow value of 1. Stretch and shrink the browser
again.
Stuck? Get a hint
3.
Assign .bottom.side a flex-grow value of 1 and .bottom.center a flex-grow value
of 2. Shrink and stretch the browser again. Compare the differences in
behavior of all three sections.
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
}
h2 {
font-size: 16px;
h1,
h2 {
text-align: center;
.top,
.middle,
.bottom {
width: 100px;
height: 100px;
background-color: dodgerblue;
.top.side {
.top.center {
}
.middle.side {
.middle.center {
.bottom.side {
.bottom.center {
#top,
#middle,
#bottom {
display: flex;
background-color: Whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Step 1</h1>
<div id='top'>
<h2>1</h2>
</div>
<h2>2</h2>
</div>
<h2>3</h2>
</div>
</div>
<h1>Step 2</h1>
<div id='middle'>
<h2>1</h2>
</div>
<h2>2</h2>
</div>
<h2>3</h2>
</div>
</div>
<h1>Step 3</h1>
<div id='bottom'>
<h2>1</h2>
</div>
<h2>2</h2>
</div>
<h2>3</h2>
</div>
</div>
</body>
</html>
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
h2 {
font-size: 16px;
h1,
h2 {
text-align: center;
.top,
.middle,
.bottom {
width: 100px;
height: 100px;
background-color: dodgerblue;
.top.side {
.top.center {
.middle.side {
.middle.center {
.bottom.side {
}
.bottom.center {
#top,
#middle,
#bottom {
display: flex;
background-color: Whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
https://www.codecademy.com/learn/paths/learn-how-to-build-websites/tracks/advanced-css-flexbox-
and-animations/modules/layout-with-flexbox/cheatsheet
https://www.codecademy.com/learn/paths/learn-how-to-build-websites/tracks/advanced-css-flexbox-
and-animations/modules/layout-with-flexbox/cheatsheet
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
h2 {
font-size: 16px;
h1,
h2 {
text-align: center;
.top,
.middle,
.bottom {
width: 100px;
height: 100px;
background-color: dodgerblue;
.top.side {
flex-grow: 1;
.top.center {
flex-grow: 1;
.middle.side {
.middle.center {
flex-grow: 1;
.bottom.side {
flex-grow: 1;
}
.bottom.center {
flex-grow: 2;
#top,
#middle,
#bottom {
display: flex;
background-color: Whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
}
FLEXBOX
flex-shrink
Just as the flex-grow property proportionally stretches flex items, the flex-
shrink property can be used to specify which elements will shrink and in what
proportions.
You may have noticed in earlier exercises that flex items shrank when the flex
container was too small, even though we had not declared the property. This
is because the default value of flex-shrink is 1. However, flex items do not
grow unless the flex-grow property is declared because the default value
of flex-grow is 0.
<div class='container'>
<div class='side'>
<h1>I'm on the side of the flex container!</h1>
</div>
<div class='center'>
<h1>I'm in the center of the flex container!</h1>
</div>
<div class='side'>
<h1>I'm on the other side of the flex container!</h1>
</div>
</div>
.container {
display: flex;
}
.side {
width: 100px;
flex-shrink: 1;
}
.center {
width: 100px;
flex-shrink: 2;
}
In the example above, the .center div will shrink twice as much as
the .side divs if the .container div is too small to fit the elements within it. If
the content is 60 pixels too large for the flex container that surrounds it,
the .center div will shrink by 30 pixels and the outer divs will shrink by 15
pixels each. Margins are unaffected by flex-grow and flex-shrink.
Keep in mind, minimum and maximum widths will take precedence over flex-
grow and flex-shrink. As with flex-grow, flex-shrink will only be employed if
the parent container is too small or the browser is adjusted.
Instructions
1.
Assign .top.side a flex-shrink value of 2.
Stretch and shrink the browser. Because the default value for flex-shrink is 1,
the .top.center div will shrink but not as much as the .side divs.
Checkpoint 2 Passed
Hint
Inside the curly braces of the .top.side selector ruleset, the flex-
shrink property should have a value of 2
selector {
property: value;
}
2.
Assign .middle.side a flex-shrink value of 0.
Stretch and shrink the browser. How do the .middle divs resize differently than
the .top divs?
Checkpoint 3 Passed
body {
margin: 0;
border: 0;
font-family: 'Roboto Mono', monospace;
h1 {
font-size: 18px;
h2 {
font-size: 16px;
h1,
h2 {
text-align: center;
.top,
.middle,
.bottom {
width: 100px;
height: 100px;
background-color: dodgerblue;
}
.top.side {
flex-shrink: 2;
.top.center {
.middle.side {
flex-shrink: 0;
.middle.center {
.bottom.side {
.bottom.center {
flex-shrink: 2;
}
#top,
#middle,
#bottom {
display: flex;
background-color: whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
}
FLEXBOX
flex-basis
In the previous two exercises, the dimensions of the divs were determined by
heights and widths set with CSS. Another way of specifying the width of a flex
item is with the flex-basis property. flex-basis allows us to specify the width
of an item before it stretches or shrinks.
<div class='container'>
<div class='side'>
<h1>Left side!</h1>
</div>
<div class='center'>
<h1>Center!</h1>
</div>
<div class='side'>
<h1>Right side!</h1>
</div>
</div>
.container {
display: flex;
}
.side {
flex-grow: 1;
flex-basis: 100px;
}
.center {
flex-grow: 2;
flex-basis: 150px;
}
In the example above, the .side divs will be 100 pixels wide and the .center div
will be 150 pixels wide if the .container div has just the right amount of space
(350 pixels, plus a little extra for margins and borders). If the .container div is
larger, the .center div will absorb twice as much space as the .side divs.
1.
In style.css, inside the .grow.side ruleset, add a flex-basis of 60px.
Checkpoint 2 Passed
Hint
To add flex-basis, use the property flex-basis.
2.
In the same rule, add a flex-grow value of 1.
Checkpoint 3 Passed
body {
margin: 0;
border: 0;
h1 {
text-align: center;
font-size: 18px;
h2 {
text-align: center;
font-size: 16px;
.grow,
.shrink {
width: 100px;
height: 100px;
background-color: dodgerblue;
.grow.side {
flex-basis: 60px;
flex-grow: 1;
.grow.center {
flex-grow: 3;
}
.shrink.side {
flex-basis: 300px;
flex-shrink: 3;
.shrink.center {
flex-shrink: 2;
flex-basis: 150px;
#grows,
#shrinks {
display: flex;
background-color: whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
<!DOCTYPE html>
<html>
<head>
<title>Flex Basis</title>
<link href='style.css' rel='stylesheet' />
</head>
<body>
<h1>Grows</h1>
<div id='grows'>
<h2>1</h2>
</div>
<h2>2</h2>
</div>
<h2>3</h2>
</div>
</div>
<h1>Shrinks</h1>
<div id='shrinks'>
<h2>1</h2>
</div>
<h2>2</h2>
</div>
<div class='shrink side'>
<h2>3</h2>
</div>
</div>
</body>
</html>
body {
margin: 0;
border: 0;
h1 {
text-align: center;
font-size: 18px;
h2 {
text-align: center;
font-size: 16px;
.grow,
.shrink {
width: 100px;
height: 100px;
background-color: dodgerblue;
.grow.side {
flex-basis: 60px;
flex-grow: 1;
.grow.center {
flex-grow: 3;
.shrink.side {
flex-basis: 300px;
flex-shrink: 3;
.shrink.center {
flex-shrink: 2;
flex-basis: 150px;
}
#grows,
#shrinks {
display: flex;
background-color: whitesmoke;
justify-content: center;
min-height: 200px;
align-items: center;
}
FLEXBOX
flex
The shorthand flex property provides a convenient way for specifying how
elements stretch and shrink, while simplifying the CSS required.
The flex property allows you to declare flex-grow, flex-shrink, and flex-
basis all in one line.
.big {
flex-grow: 2;
flex-shrink: 1;
flex-basis: 150px;
}
.small {
flex-grow: 1;
flex-shrink: 2;
flex-basis: 100px;
}
In the example above, all elements with class big will grow twice as much as
elements with class small. Keep in mind, this doesn’t mean big items will be
twice as big as small items, they’ll just take up more of the extra space.
.big {
flex: 2 1 150px;
}
.small {
flex: 1 2 100px;
}
In the example above, we use the flex property to declare the values for flex-
grow, flex-shrink, and flex-basis (in that order) all in one line.
.big {
flex: 2 1;
}
In the example above, we use the flex property to declare flex-grow and flex-
shrink, but not flex-basis.
.small {
flex: 1 20px;
}
In the example above, we use the flex property to declare flex-grow and flex-
basis. Note that there is no way to set only flex-shrink and flex-basis using 2
values.
The browser to the right has two flex containers, each with three flex items.
In style.css, examine the values for each of these items. Notice that the flex-
grow and flex-basis values are set for the blue divs.
Stretch the browser window to increase its width. Observe that once the top
outer divs reach 100 pixels wide, they begin to grow faster than the top
center div. Also notice that once the bottom center div reaches 100 pixels
wide, it begins to grow faster than the outer divs.
Now, shrink the browser window and notice that once the top
center div reaches 50 pixels wide it begins to shrink faster than the outer divs
and when the bottom outer divs reach 75 pixels, they begin to shrink faster
than the center div.
Instructions
1.
In #top .side, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line using the
shorthand flex property.
Stuck? Get a hint
2.
In #top .center, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line.
Stuck? Get a hint
3.
In #bottom .side, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line.
Stuck? Get a hint
4.
In #bottom .center, all three values for flex-grow, flex-shrink, and flex-
basis are assigned individually. Refactor them to be declared in one line
FLEXBOX
flex
The shorthand flex property provides a convenient way for specifying how
elements stretch and shrink, while simplifying the CSS required.
The flex property allows you to declare flex-grow, flex-shrink, and flex-
basis all in one line.
.big {
flex-grow: 2;
flex-shrink: 1;
flex-basis: 150px;
}
.small {
flex-grow: 1;
flex-shrink: 2;
flex-basis: 100px;
}
In the example above, all elements with class big will grow twice as much as
elements with class small. Keep in mind, this doesn’t mean big items will be
twice as big as small items, they’ll just take up more of the extra space.
.big {
flex: 2 1 150px;
}
.small {
flex: 1 2 100px;
}
In the example above, we use the flex property to declare the values for flex-
grow, flex-shrink, and flex-basis (in that order) all in one line.
.big {
flex: 2 1;
}
In the example above, we use the flex property to declare flex-grow and flex-
shrink, but not flex-basis.
.small {
flex: 1 20px;
}
In the example above, we use the flex property to declare flex-grow and flex-
basis. Note that there is no way to set only flex-shrink and flex-basis using 2
values.
The browser to the right has two flex containers, each with three flex items.
In style.css, examine the values for each of these items. Notice that the flex-
grow and flex-basis values are set for the blue divs.
Stretch the browser window to increase its width. Observe that once the top
outer divs reach 100 pixels wide, they begin to grow faster than the top
center div. Also notice that once the bottom center div reaches 100 pixels
wide, it begins to grow faster than the outer divs.
Now, shrink the browser window and notice that once the top
center div reaches 50 pixels wide it begins to shrink faster than the outer divs
and when the bottom outer divs reach 75 pixels, they begin to shrink faster
than the center div.
Instructions
1.
In #top .side, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line using the
shorthand flex property.
Stuck? Get a hint
2.
In #top .center, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line.
Stuck? Get a hint
3.
In #bottom .side, all three values for flex-grow, flex-shrink, and flex-basis are
assigned individually. Refactor them to be declared in one line.
Stuck? Get a hint
4.
In #bottom .center, all three values for flex-grow, flex-shrink, and flex-
basis are assigned individually. Refactor them to be declared in one line
body {
border: 0;
margin: 0 15px;
h1 {
text-align: center;
display: block;
font-size: 18px;
.container {
height: 150px;
width: 100%;
display: flex;
background-color: whitesmoke;
.side,
.center {
height: 75px;
background-color: dodgerblue;
display: inline-block;
#top .side {
flex: 2 2 100px;
#top .center {
flex: 1 3 50px;
#bottom .side {
flex: 1 2 75px;
#bottom .center {
flex: 2 1 100px;
}
body {
h1 {
font-size: 18px;
h1,
h3 {
text-align: center;
.container {
background-color: dodgerblue;
display: flex;
align-items: center;
min-height: 125px;
.box {
background-color: whitesmoke;
width: 100px;
height: 100px;
}
#wrap {
#nowrap {
#reverse {
}
FLEXBOX
flex-wrap
Sometimes, we don’t want our content to shrink to fit its container. Instead, we
might want flex items to move to the next line when necessary. This can be
declared with the flex-wrap property. The flex-wrap property can accept three
values:
1. wrap — child elements of a flex container that don’t fit into a row will
move down to the next line
2. wrap-reverse — the same functionality as wrap, but the order of rows
within a flex container is reversed (for example, in a 2-row flexbox, the
first row from a wrap container will become the second in wrap-
reverse and the second row from the wrap container will become the first
in wrap-reverse)
3. nowrap — prevents items from wrapping; this is the default value and is
only necessary to override a wrap value set by a different CSS rule.
<div class='container'>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
</div>
.container {
display: inline-flex;
flex-wrap: wrap;
width: 250px;
}
.item {
width: 100px;
height: 100px;
}
In the example above, three flex items are contained by a parent flex
container. The flex container is only 250 pixels wide so the three 100 pixel
wide flex items cannot fit inline. The flex-wrap: wrap; setting causes the third,
overflowing item to appear on a new line, below the other two items.
Instructions
1.
In style.css, inside the #wrap ruleset, add a flex-wrap property with a value
of wrap. Shrink and stretch the browser.
Stuck? Get a hint
2.
Inside the #nowrap ruleset, add a flex-wrap property with a value of nowrap.
Shrink and stretch the browser.
Stuck? Get a hint
3.
Inside the #reverse ruleset, add a flex-wrap property with a value of wrap-
reverse. Shrink and stretch the browser.
Stuck? Get a hint
4.
Inside the .container ruleset, add a justify-content property with a value
of space-around. Stretch and shrink the browser. What’s different this time?
FLEXBOX
flex-wrap
Sometimes, we don’t want our content to shrink to fit its container. Instead, we
might want flex items to move to the next line when necessary. This can be
declared with the flex-wrap property. The flex-wrap property can accept three
values:
1. wrap — child elements of a flex container that don’t fit into a row will
move down to the next line
2. wrap-reverse — the same functionality as wrap, but the order of rows
within a flex container is reversed (for example, in a 2-row flexbox, the
first row from a wrap container will become the second in wrap-
reverse and the second row from the wrap container will become the first
in wrap-reverse)
3. nowrap — prevents items from wrapping; this is the default value and is
only necessary to override a wrap value set by a different CSS rule.
<div class='container'>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
<div class='item'>
<h1>We're going to wrap!</h1>
</div>
</div>
.container {
display: inline-flex;
flex-wrap: wrap;
width: 250px;
}
.item {
width: 100px;
height: 100px;
}
In the example above, three flex items are contained by a parent flex
container. The flex container is only 250 pixels wide so the three 100 pixel
wide flex items cannot fit inline. The flex-wrap: wrap; setting causes the third,
overflowing item to appear on a new line, below the other two items.
Instructions
1.
In style.css, inside the #wrap ruleset, add a flex-wrap property with a value
of wrap. Shrink and stretch the browser.
Checkpoint 2 Passed
Hint
Be sure to use the value nowrap this time!
3.
Inside the #reverse ruleset, add a flex-wrap property with a value of wrap-
reverse. Shrink and stretch the browser.
Checkpoint 4 Passed
Hint
Inside the curly braces of the .container selector ruleset, the justify-
content property should have a value of space-around .
selector {
property: value;
}
body {
}
h1 {
font-size: 18px;
h1,
h3 {
text-align: center;
.container {
justify-content:space-around;
background-color: dodgerblue;
display: flex;
align-items: center;
min-height: 125px;
.box {
background-color: whitesmoke;
width: 100px;
height: 100px;
}
#wrap {
flex-wrap:wrap;
#nowrap {
flex-wrap:nowrap;
#reverse {
flex-wrap:wrap-reverse;
<!DOCTYPE html>
<html>
<head>
<title>Wrap</title>
</head>
<body>
<h1>Flex-Wrap: Wrap</h1>
<div class='box'>
<h3>1</h3>
</div>
<div class='box'>
<h3>2</h3>
</div>
<div class='box'>
<h3>3</h3>
</div>
<div class='box'>
<h3>4</h3>
</div>
<div class='box'>
<h3>5</h3>
</div>
</div>
<h1>Flex-Wrap: No-Wrap</h1>
<div class='box'>
<h3>1</h3>
</div>
<div class='box'>
<h3>2</h3>
</div>
<div class='box'>
<h3>3</h3>
</div>
<div class='box'>
<h3>4</h3>
</div>
<div class='box'>
<h3>5</h3>
</div>
</div>
<h1>Flex-Wrap: Wrap-Reverse</h1>
<div class='box'>
<h3>1</h3>
</div>
<div class='box'>
<h3>2</h3>
</div>
<div class='box'>
<h3>3</h3>
</div>
<div class='box'>
<h3>4</h3>
</div>
<div class='box'>
<h3>5</h3>
</div>
</div>
</body>
</html>
FLEXBOX
align-content
Now that elements can wrap to the next line, we might have multiple rows of
flex items within the same container. In a previous exercise, we used the align-
items property to space flex items from the top to the bottom of a flex
container. align-items is for aligning elements within a single row. If a flex
container has multiple rows of content, we can use align-content to space the
rows from top to bottom.
<div class='container'>
<div class='child'>
<h1>1</h1>
</div>
<div class='child'>
<h1>2</h1>
</div>
<div class='child'>
<h1>3</h1>
</div>
<div class='child'>
<h1>4</h1>
</div>
</div>
.container {
display: flex;
width: 400px;
height: 400px;
flex-wrap: wrap;
align-content: space-around;
}
.child {
width: 150px;
height: 150px;
}
In the example above, there are four flex items inside of a flex container. The
flex items are set to be 150 pixels wide each, but the parent container is only
400 pixels wide. This means that no more than two elements can be displayed
inline. The other two elements will wrap to the next line and there will be two
rows of divs inside of the flex container. The align-content property is set to
the value of space-around, which means the two rows of divs will be evenly
spaced from top to bottom of the parent container with equal space before
the first row and after the second, with double space between the rows.
Instructions
1.
In style.css, inside the #flexstart ruleset, add an align-content property with a
value of flex-start to position the rows of elements at the top of the parent
container.
Stuck? Get a hint
2.
In style.css, inside the #flexend ruleset, add an align-content property with a
value of flex-end to position the rows of elements at the bottom of the parent
container.
Stuck? Get a hint
3.
In style.css, inside the #center ruleset, add an align-content property with a
value of center to position the rows of elements at the center of the parent
container.
Stuck? Get a hint
4.
In style.css, inside the #between ruleset, add an align-content property with a
value of space-between to space out all of the rows of elements evenly with
equal space between each row.
Stuck? Get a hint
5.
In style.css, inside the #around ruleset, add an align-content property with a
value of space-around to space out all of the rows of elements evenly with
equal space around each row.
Stuck? Get a hint
6.
Inside the .left, .center, .right ruleset, change the height property to min-
height. What happens to the flex items in the #stretch container?
body {
h1 {
margin: 20px;
text-align: center;
font-size: 18px;
}
.container {
height: 300px;
width: 600px;
background-color: whitesmoke;
display: flex;
flex-wrap: wrap;
margin: auto;
.left,
.center,
.right {
height: 75px;
width: 200px;
margin: 2px;
background-color: dodgerblue;
#flexstart {
#flexend {
}
#center {
#between {
#around {
body {
h1 {
margin: 20px;
text-align: center;
font-size: 18px;
.container {
height: 300px;
width: 600px;
background-color: whitesmoke;
display: flex;
flex-wrap: wrap;
margin: auto;
.left,
.center,
.right {
min-height: 75px;
width: 200px;
margin: 2px;
background-color: dodgerblue;
#flexstart {
align-content: flex-start;
#flexend {
align-content: flex-end;
}
#center {
align-content: center;
#between {
align-content: space-between;
#around {
align-content: space-around;
}
FLEXBOX
flex-direction
Up to this point, we’ve only covered flex items that stretch and shrink
horizontally and wrap vertically. As previously stated, flex containers have two
axes: a main axis and a cross axis. By default, the main axis is horizontal and
the cross axis is vertical.
The main axis is used to position flex items with the following properties:
1. justify-content
2. flex-wrap
3. flex-grow
4. flex-shrink
The cross axis is used to position flex items with the following properties:
1. align-items
2. align-content
The main axis and cross axis are interchangeable. We can switch them using
the flex-direction property. If we add the flex-direction property and give it a
value of column, the flex items will be ordered vertically, not horizontally.
<div class='container'>
<div class='item'>
<h1>1</h1>
</div>
<div class='item'>
<h1>2</h1>
</div>
<div class='item'>
<h1>3</h1>
</div>
<div class='item'>
<h1>4</h1>
</div>
<div class="item">
<h1>5</h1>
</div>
</div>
.container {
display: flex;
flex-direction: column;
width: 1000px;
}
.item {
height: 100px;
width: 100px;
}
In the example above, the five divs will be positioned in a vertical column. All
of these divs could fit in one horizontal row. However, the column value tells
the browser to stack the divs one on top of the other. As explained above,
properties like justify-content will not behave the way they did in previous
examples.
1. row — elements will be positioned from left to right across the parent
element starting from the top left corner (default).
2. row-reverse — elements will be positioned from right to left across the
parent element starting from the top right corner.
3. column — elements will be positioned from top to bottom of the parent
element starting from the top left corner.
4. column-reverse — elements will be positioned from the bottom to the
top of the parent element starting from the bottom left corner.
Instructions
1.
In style.css, inside the #row ruleset, add a flex-direction property with a value
of row.
Checkpoint 2 Passed
Hint
Inside the curly braces of the #row selector ruleset, the flex-direction property
should have a value of row.
selector {
property: value;
}
2.
Inside the #row-reverse ruleset, add a flex-direction property with a value
of row-reverse.
Checkpoint 3 Passed
Hint
This time, the flex-direction property gets a value of row-reverse.
3.
Inside the #column ruleset, add a flex-direction property with a value of column.
Checkpoint 4 Passed
Hint
This time. the value is column.
4.
Inside the #column-reverse ruleset, add a flex-direction property with a value
of column-reverse.
Checkpoint 5 Passed
Hint
The value used here will be column-reverse.
5.
Change the height property of .container elements to be max-height.
Remember to stretch and shrink the browser after each checkpoint so you can
see the effects.
Checkpoint 6 Passed
Hint
Inside the .container ruleset, change the height property to be max-height.
6.
Inside the .container ruleset, add an align-items property with a value
of center.
Checkpoint 7 Passed
Hint
Inside the curly braces of the .container selector ruleset, the align-
items property should have a value of center.
selector {
property: value;
}
7.
Inside the .container ruleset, add a justify-content property with a value
of space-around.
Checkpoint 8 Passed
Hint
Inside the curly braces of the .container selector ruleset, the justify-
content property should have a value of space-around.
selector {
property: value;
}
8.
Inside the .box ruleset, add a flex-grow property with a value of 1. In which
direction do the elements grow?
Checkpoint 9 Passed
Hint
Inside the curly braces of the .box selector ruleset, the flex-grow property
should have a value of 1.
selector {
property: value;
}
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
h2 {
font-size: 14px;
h1,
h2 {
text-align: center;
.container {
background-color: dodgerblue;
display: flex;
max-height: 600px;
align-items:center;
justify-content:space-around;
.box {
background-color: whitesmoke;
width: 100px;
height: 100px;
flex-grow:1;
}
#row {
flex-direction:row;
#row-reverse {
flex-direction:row-reverse;
#column {
flex-direction:column;
#column-reverse {
flex-direction:column-reverse;
}
FLEXBOX
flex-flow
Like the shorthand flex property, the shorthand flex-flow property is used to declare both
the flex-wrap and flex-direction properties in one line.
.container {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
In the example above, we take two lines to accomplish what can be done with one.
.container {
display: flex;
flex-flow: column wrap;
}
In the example above, the first value in the flex-flow declaration is a flex-direction value and
the second is a flex-wrap value. All values for flex-direction and flex-wrap are accepted.
Instructions
1.
In the #row-reverse ruleset, set the flex-flow property to have a direction of row-reverse and
to wrap elements. You should be able to accomplish this in one line.
Hint
The flex-flow property should have a value of row-reverse wrap.
2.
In the #column ruleset, set the flex-flow property to give elements a direction of column and
to wrap elements. You should be able to accomplish this in one line.
Hint
The flex-flow property should have a value of column wrap.
Concept Review
Want to quickly review some of the concepts you’ve been learning? Take a look at this
material's cheatsheet!
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
h2 {
font-size: 14px;
h1, h2 {
text-align: center;
.container {
background-color: dodgerblue;
display: flex;
height: 600px;
align-items: center;
.box {
background-color: whitesmoke;
width: 100px;
height: 100px;
}
#row {
#row-reverse {
#column {
#column-reverse {
<!DOCTYPE html>
<html>
<head>
<title>Direction</title>
</head>
<body>
<h1>Flex-Direction: Row</h1>
<div class='box'>
<h2>1</h2>
</div>
<div class='box'>
<h2>2</h2>
</div>
<div class='box'>
<h2>3</h2>
</div>
<div class='box'>
<h2>4</h2>
</div>
<div class='box'>
<h2>5</h2>
</div>
</div>
<h1>Flex-Direction: Row-Reverse</h1>
<div class='box'>
<h2>1</h2>
</div>
<div class='box'>
<h2>2</h2>
</div>
<div class='box'>
<h2>3</h2>
</div>
<div class='box'>
<h2>4</h2>
</div>
<div class='box'>
<h2>5</h2>
</div>
</div>
<h1>Flex-Direction: Column</h1>
<div class='box'>
<h2>1</h2>
</div>
<div class='box'>
<h2>2</h2>
</div>
<div class='box'>
<h2>3</h2>
</div>
<div class='box'>
<h2>4</h2>
</div>
<div class='box'>
<h2>5</h2>
</div>
</div>
<h1>Flex-Direction: Column-Reverse</h1>
<div class='box'>
<h2>1</h2>
</div>
<div class='box'>
<h2>2</h2>
</div>
<div class='box'>
<h2>3</h2>
</div>
<div class='box'>
<h2>4</h2>
</div>
<div class='box'>
<h2>5</h2>
</div>
</div>
</body>
</html>
body {
margin: 0;
border: 0;
h1 {
font-size: 18px;
h2 {
font-size: 14px;
h1, h2 {
text-align: center;
.container {
background-color: dodgerblue;
display: flex;
height: 600px;
align-items: center;
}
.box {
background-color: whitesmoke;
width: 100px;
height: 100px;
#row {
#row-reverse {
#column {
#column-reverse {
FLEXBOX
Nested Flexboxes
So far, we’ve had multiple flex containers on the same page to explore flex
item positioning. It is also possible to position flex containers inside of one
another.
<div class='container'>
<div class='left'>
<img class='small' src='#'/>
<img class='small' src='#'/>
<img class='small' src='#' />
</div>
<div class='right'>
<img class='large' src='#' />
</div>
</div>
.container {
display: flex;
justify-content: center;
align-items: center;
}
.left {
display: inline-flex;
flex: 2 1 200px;
flex-direction: column;
}
.right {
display: inline-flex;
flex: 1 2 400px;
align-items: center;
}
.small {
height: 200px;
width: auto;
}
.large {
height: 600px;
width: auto;
}
In the example above, a div with three smaller images will display from top to
bottom on the left of the page (.left). There is also a div with one large image
that will display on the right side of the page (.right). The left div has a
smaller flex-basis but stretches to fill more extra space; the right div has a
larger flex-basis but stretches to fill less extra space. Both divs are flex
items and flex containers. The items have properties that dictate how they will
be positioned in the parent container and how their flex item children will be
positioned in them.
We’ll use the same formatting above to layout the simple page to the right.
Instructions
1.
Inside the .main ruleset, add a display property with a value of flex.
Hint
Inside the curly braces of the .main selector ruleset, the display property
should have a value of flex.
selector {
property: value;
}
2.
Inside the .main ruleset, add an align-items property with a value of center.
Hint
The value used in this step will be center.
3.
Inside the .main ruleset, add a justify-content property with a value of space-
around.
Hint
The value used in this step will be space-around.
4.
Inside the .container ruleset, add a display property with a value of flex.
Hint
The value used in this step will be flex.
5.
Inside the .container ruleset, add a flex-direction property with a value
of column.
Hint
The value used in this step will be column.
6.
Inside the .container ruleset, add a justify-content property with a value
of center.
Stuck? Get a hint
7.
Inside the .container ruleset, add an align-items property with a value
of center.
Hint
The value used in this step will be center.
8.
Repeat steps 4, 6, and 7 for the .child ruleset.
Hint
Inside the .child ruleset:
body {
h2 {
text-align: center;
font-size: 18px;
.main {
background-color: lightgrey;
width: 400px;
height: 700px;
.container {
width: 300px;
height: 300px;
background-color: dodgerblue;
.child {
height: 75px;
width: 75px;
background-color: whitesmoke;
}
FLEXBOX
Nested Flexboxes
So far, we’ve had multiple flex containers on the same page to explore flex
item positioning. It is also possible to position flex containers inside of one
another.
<div class='container'>
<div class='left'>
<img class='small' src='#'/>
<img class='small' src='#'/>
<img class='small' src='#' />
</div>
<div class='right'>
<img class='large' src='#' />
</div>
</div>
.container {
display: flex;
justify-content: center;
align-items: center;
}
.left {
display: inline-flex;
flex: 2 1 200px;
flex-direction: column;
}
.right {
display: inline-flex;
flex: 1 2 400px;
align-items: center;
}
.small {
height: 200px;
width: auto;
}
.large {
height: 600px;
width: auto;
}
In the example above, a div with three smaller images will display from top to
bottom on the left of the page (.left). There is also a div with one large image
that will display on the right side of the page (.right). The left div has a
smaller flex-basis but stretches to fill more extra space; the right div has a
larger flex-basis but stretches to fill less extra space. Both divs are flex
items and flex containers. The items have properties that dictate how they will
be positioned in the parent container and how their flex item children will be
positioned in them.
We’ll use the same formatting above to layout the simple page to the right.
Instructions
1.
Inside the .main ruleset, add a display property with a value of flex.
Checkpoint 2 Passed
Hint
Inside the curly braces of the .main selector ruleset, the display property
should have a value of flex.
selector {
property: value;
}
2.
Inside the .main ruleset, add an align-items property with a value of center.
Checkpoint 3 Passed
Hint
The value used in this step will be center.
3.
Inside the .main ruleset, add a justify-content property with a value of space-
around.
Checkpoint 4 Passed
Hint
The value used in this step will be space-around.
4.
Inside the .container ruleset, add a display property with a value of flex.
Checkpoint 5 Passed
Hint
The value used in this step will be flex.
5.
Inside the .container ruleset, add a flex-direction property with a value
of column.
Checkpoint 6 Passed
Hint
The value used in this step will be column.
6.
Inside the .container ruleset, add a justify-content property with a value
of center.
Checkpoint 7 Passed
Hint
The value used in this step will be center.
8.
Repeat steps 4, 6, and 7 for the .child ruleset.
Checkpoint 9 Passed
Hint
Inside the .child ruleset:
Let’s apply a few of the properties you’ve learned to arrange one section of
the web page in the browser to the right!
Instructions
1.
All of the images are inside of three column divs and the three column divs
are all inside of one large div called .cards.
selector {
property: value;
}
2.
Now, inside the .cards ruleset, set the flex-wrap property to have a value
of wrap.
Hint
flex-wrap should have a value of wrap.
3.
Inside the .cards ruleset, set the justify-content property to have a value
of space-around.
Hint
justify-content should have a value of space-around.
4.
In the .col ruleset, set the display property to have a value of inline-flex.
Hint
The declaration should be display: inline-flex;
5.
In the .col ruleset, set the flex-direction property to have a value of column.
Hint
Inside the curly braces of the .col selector ruleset, the flex-direction property
should have a value of column.
selector {
property: value;
}
6.
In the .col ruleset, set the justify-content property to have a value of space-
between.
Hint
Inside the curly braces of the .col selector ruleset, the justify-
content property should have a value of space-between.
selector {
property: value;
}
html, body {
margin: 0;
padding: 0;
img {
height: auto;
width: auto;
ul {
text-align: right;
h1 {
font-size: 20px;
/*Sizing*/
.container {
margin: 0 auto;
}
.spacer {
max-width: 1200px;
margin: auto;
.main {
background-color: #ffc200;
/*Header Section*/
.header {
margin-left: 50px;
margin-right: 50px;
.header li {
list-style: none;
display: inline-block;
.header li a {
color: #333;
margin:0;
border:0px;
/*Jumbotron Section*/
.jumbotron {
background-color: #fff;
max-width: 1200px;
margin-left: 50px;
.jumbotron h2 {
font-size: 50px;
margin-bottom: 70px;
.jumbotron h2 span {
color:#ffc200;
.jumbotron p {
text-shadow: 0 0;
font-size: 16px;
color: #666;
margin-bottom: 0;
/*Banner Section*/
.banner {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
/*Expertise Section*/
.cards {
background-color: #ffc200;
.col {
#expertise {
padding: 20px;
background-color: #ffc200;
margin: 0;
text-align: center;
}
/*Footer Section*/
.footer {
background-color: #000;
color: #fff;
.footer h3 {
font-size: 20px;
margin-left: 20px;
.footer p {
font-size:12px;
margin-bottom: 0;
margin-left: 20px;
}
html, body {
margin: 0;
padding: 0;
img {
height: auto;
width: auto;
ul {
text-align: right;
h1 {
font-size: 20px;
/*Sizing*/
.container {
margin: 0 auto;
}
.spacer {
max-width: 1200px;
margin: auto;
.main {
background-color: #ffc200;
/*Header Section*/
.header {
margin-left: 50px;
margin-right: 50px;
.header li {
list-style: none;
display: inline-block;
.header li a {
color: #333;
margin:0;
border:0px;
/*Jumbotron Section*/
.jumbotron {
background-color: #fff;
max-width: 1200px;
margin-left: 50px;
.jumbotron h2 {
font-size: 50px;
margin-bottom: 70px;
.jumbotron h2 span {
color:#ffc200;
.jumbotron p {
text-shadow: 0 0;
font-size: 16px;
color: #666;
margin-bottom: 0;
/*Banner Section*/
.banner {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
/*Expertise Section*/
.cards {
background-color: #ffc200;
display:flex;
flex-wrap:wrap;
justify-content:space-around;;
.col {
display:inline-flex;
flex-direction:column;
justify-content:space-between;
}
#expertise {
padding: 20px;
background-color: #ffc200;
margin: 0;
text-align: center;
/*Footer Section*/
.footer {
background-color: #000;
color: #fff;
.footer h3 {
font-size: 20px;
margin-left: 20px;
.footer p {
font-size:12px;
margin-bottom: 0;
margin-left: 20px;
}
ADVANCED CSS: FLEXBOX AND CSS TRANSITIONS
Flexbox: To-Do App
In this project, you will follow step-by-step instructions to fix a to-do web app. All of the
HTML and most of the CSS is intact, however, a few Flexbox values are missing.
In order to complete this project, you must know how to set an element’s Flexbox
properties.
<!DOCTYPE html>
<html>
<head>
<title>To Do App</title>
</head>
<body>
<div id='header'>
</div>
<!-- App Container -->
<div class='container'>
<div class='week'>
</div>
</div>
<div class='row'>
</div>
</div>
<div class='row'>
</div>
</div>
</div>
<div class='reminders'>
<h3>Reminders</h3>
</div>
</div>
<footer>
</footer>
</body>
</html>
/* Universal Styles */
body {
margin: 0px;
background-color: whitesmoke;
text-align: center;
.secondary-background {
background-color: snow;
.tagline {
color: lightslategrey;
line-height: 125px;
/* Header */
h1 {
margin: 0;
background-color: steelblue;
line-height: 100px;
color: khaki;
}
h2 {
margin: 10px;
/* App Container */
.container {
/* To Do Section */
.week {
.row {
min-height: 200px;
display: flex;
.square {
width: 125px;
height: 125px;
padding: 10px;
}
.day.square {
background-color: steelblue;
.task.square {
background-color: khaki;
.task p {
font-weight: 700;
font-size: 12px;
/* Reminders */
.reminders {
background-color: khaki;
.reminders h3 {
width: 100%;
margin: 10px;
color: black;
line-height: 90px;
font-size: 24px;
/* Footer */
footer {
font-size: 24px;
}
ADVANCED CSS: FLEXBOX AND CSS TRANSITIONS
Flexbox: To-Do App
In this project, you will follow step-by-step instructions to fix a to-do web app.
All of the HTML and most of the CSS is intact, however, a few Flexbox values
are missing.
In order to complete this project, you must know how to set an element’s
Flexbox properties.
If you get stuck during this project, check out the project walkthrough
video which can be found in the help menu.
Tasks
6/6 Complete
Mark the tasks as complete by checking them off
1.
Start off by turning some of the elements into flex and inline-flex containers.
display: flex;
The .week and .reminders rulesets get the declaration:
display: inline-flex;
2.
The elements inside the new inline-flex containers should grow to fill the
container. This is accomplished using the flex-grow property:
Hint
The .week ruleset declaration should be:
flex-grow: 3;
The .reminders ruleset declaration should be:
flex-grow: 2;
3.
We want the flex items with the class week to be ordered vertically, instead of
horizontally.
You did it! Great work. Now resize the browser to see your flex properties in
action!
Hint
The align-items property gets a value of center in order to center the items!
/* Universal Styles */
body {
margin: 0px;
background-color: whitesmoke;
text-align: center;
.secondary-background {
background-color: snow;
}
.tagline {
color: lightslategrey;
line-height: 125px;
/* Header */
h1 {
margin: 0;
background-color: steelblue;
line-height: 100px;
color: khaki;
h2 {
margin: 10px;
/* App Container */
.container {
display: flex;
}
/* To Do Section */
.week {
display:inline-flex;
flex-grow: 3;
flex-direction:column;
justify-content:space-around;
.row {
flex-wrap:wrap;
min-height: 200px;
display: flex;
align-items:center;
.square {
display: flex;
width: 125px;
height: 125px;
padding: 10px;
justify-content:center;
align-items:center;
}
.day.square {
background-color: steelblue;
.task.square {
background-color: khaki;
.task p {
font-weight: 700;
font-size: 12px;
/* Reminders */
.reminders {
display:inline-flex;
background-color: khaki;
.reminders h3 {
width: 100%;
margin: 10px;
color: black;
line-height: 90px;
font-size: 24px;
/* Footer */
footer {
font-size: 24px;
}
ADVANCED CSS: FLEXBOX AND CSS TRANSITIONS
Tea Cozy
In this project, you will create a fictional tea shop website on your own computer.
We will provide a design spec and image assets to help you along the way. A design
spec is an image of a web page outlined with all of its CSS properties and values. These
are usually created by a designer as a source of instructions for a web developer. This
project assumes that you will be able to reproduce the basic HTML and CSS with little
guidance.
The images and design spec you need to complete the project are listed below.
Images:
1. Logo
2. Bedford Bizarre
3. Berry Blitz
4. Donut
5. Locations
6. Background
7. Myrtle Ave
8. Spiced Rum
Design Spec:
Good luck!
https://content.codecademy.com/courses/freelance-1/unit-4/img-tea-cozy-redline.jpg
https://content.codecademy.com/courses/freelance-1/unit-4/img-bedford-bizarre.jpg
CSS TRANSITIONS
CSS Transitions
After a website is displayed, the visual appearances of various elements can
change for many reasons. For example:
Moving your mouse over a link may change the color or appearance of
that link.
Changing the size of the window may change the layout.
Scrolling causes some elements to disappear and others to appear.
These changes are a type of state change. CSS transitions allow us to control
the timing of visual state changes. We can control the following four aspects
of an element’s transition:
We’ll explore how different answers to each of these questions changes the
animation. If any of these sound confusing, don’t worry! We will look at
examples of each and learn how to use them together for a visually pleasing
experience.
Instructions
1.
The web page in the browser contains a link styled as a button.
Currently, the background color abruptly changes from orange to green when
you move your mouse over it. Let’s make this transition smoother.
a{
display: block;
width: 300px;
border-radius: 5px;
background-color: orange;
text-align: center;
font-family: Helvetica;
font-size: 32px;
color: mintcream;
transition-property: background-color;
transition-duration: 2s;
a:hover {
background-color: limegreen;
}
a{
display: block;
width: 300px;
border-radius: 5px;
background-color: orange;
text-align: center;
font-family: Helvetica;
font-size: 32px;
color: mintcream;
transition-property: background-color;
transition-duration: 2s;
a:hover {
background-color: limegreen;
}
CSS TRANSITIONS
Duration
To create a simple transition in CSS, we must specify two of the four aspects:
a {
transition-property: color;
transition-duration: 1s;
}
In the example above, transition-property declares which CSS property we will
be transitioning, the text color. The second property, transition-duration,
declares how long the transition will take — one second.
When choosing a duration, think about how long actions take in real life. For
example, a human eye blink takes around 400ms. People might expect the
animation of clicking a button to be as sudden as a blink.
Instructions
1.
The background-color transition we implemented in the last exercise is a little
slow. The user may move their mouse away before they notice the color
changing!
Ultimately, it’s up to you how long your animation takes; there is no right or
wrong value. Experiment and have fun!
Hint
a{
display: block;
width: 300px;
border-radius: 5px;
background-color: orange;
text-align: center;
font-family: Helvetica;
font-size: 32px;
color: mintcream;
transition-property: background-color;
transition-duration: 2s;
a:hover {
background-color: limegreen;
}
CSS TRANSITIONS
Timing Function
The default value is ease, which starts the transition slowly, speeds up in the
middle, and slows down again at the end.
transition-property: color;
transition-duration: 1s;
transition-timing-function: ease-out;
In the example above, the text color will be animated over one second. The
timing function is ease-out which means it will begin abruptly and slow down
as it ends.
If you’re interested in learning more about timing functions or seeing a full list
of the possible values, we recommend this resource from the Mozilla
Developer Network.
Instructions
1.
html,
body {
margin-top: 50px;
height: 100%;
text-align: center;
font-size: 16px;
h1 {
font-size: 40px;
.game {
position: relative;
display: inline-block;
height: 60%;
.game img {
cursor: pointer;
.game .safari {
margin-top: 50px;
height: 430.188px;
width: 573.578px;
.game .gazelle {
position: absolute;
top: 260px;
left: 231px;
z-index: 1;
max-height: 50px;
transition-property: max-height;
transition-duration: 750ms;
.game .gazelle:hover {
max-height: 180px;
https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function
https://github.com/mdn/content/blob/main/files/en-us/web/css/transition-timing-function/index.html
CSS TRANSITIONS
Timing Function
The next transition property is transition-timing-function. The timing function describes the
pace of the transition.
The default value is ease, which starts the transition slowly, speeds up in the middle, and slows
down again at the end.
transition-property: color;
transition-duration: 1s;
transition-timing-function: ease-out;
In the example above, the text color will be animated over one second. The timing function
is ease-out which means it will begin abruptly and slow down as it ends.
If you’re interested in learning more about timing functions or seeing a full list of the possible
values, we recommend this resource from the Mozilla Developer Network.
Instructions
1.
Hover your mouse over the gazelle to observe the difference in motion. If you can’t tell the
difference, you can change the transition-duration value to be longer.
Checkpoint 2 Passed
Hint
html,
body {
margin-top: 50px;
height: 100%;
text-align: center;
font-size: 16px;
h1 {
font-size: 40px;
.game {
position: relative;
display: inline-block;
height: 60%;
.game img {
cursor: pointer;
.game .safari {
margin-top: 50px;
height: 430.188px;
width: 573.578px;
}
.game .gazelle {
position: absolute;
top: 260px;
left: 231px;
z-index: 1;
max-height: 50px;
transition-property: max-height;
transition-duration: 750ms;
transition-timing-function:linear;
.game .gazelle:hover {
max-height: 180px;
CSS TRANSITIONS
Delay
Our last transition property is transition-delay. Much like duration, its value is
an amount of time. Delay specifies the time to wait before starting the
transition. As with the duration property, the default value for transition-
delay is 0s, which means no delay.
transition-property: width;
transition-duration: 750ms;
transition-delay: 250ms;
In the example above, a change in the width of the element will start after a
quarter of a second, and it will animate over three quarters of a second.
Instructions
1.
Right now the gazelle immediately begins the transition to the new state when
the mouse hovers over it. Let’s add a delay to make the game a little more
interesting.
html,
body {
margin-top: 50px;
height: 100%;
text-align: center;
font-size: 16px;
h1 {
font-size: 40px;
.game {
position: relative;
display: inline-block;
height: 60%;
.game img {
cursor: pointer;
.game .safari {
margin-top: 50px;
height: 430.188px;
width: 573.578px;
.game .gazelle {
position: absolute;
top: 260px;
left: 231px;
z-index: 1;
max-height: 50px;
transition-property: max-height;
transition-duration: 750ms;
transition-timing-function: linear;
transition-delay:400ms;
}
.game .gazelle:hover {
max-height: 180px;
}
CSS TRANSITIONS
Shorthand
Now that we’ve explored each transition property, you may find yourself with
many CSS rule sets that look like the code below.
transition-property: color;
transition-duration: 1.5s;
transition-timing-function: linear;
transition-delay: 0.5s;
Because these four properties are so frequently declared together, CSS
provides a property that can be used to declare them all in one
line: transition. This shorthand property describes each aspect of the
transition puzzle in a single declaration. The properties must be specified in
this order: transition-property, transition-duration, transition-timing-
function, transition-delay.
Leaving out one of the properties causes the default value for that property to
be applied. There is one exception: You must set duration if you want to
define delay. Since both are time values, the browser will always interpret the
first time value it sees as duration.
Instructions
1.
Combine all the transition properties for the gazelle into one, shorthand
declaration. The property being transitioned is max-height, with a duration
of 750ms. The timing function is linear, and the delay is 400ms.
Hint
The transition shorthand property uses the properties from all 4 existing
transition properties in this order: transition-property transition-
duration transition-timing-function transition-delay.
html,
body {
margin-top: 50px;
height: 100%;
text-align: center;
font-size: 16px;
h1 {
font-size: 40px;
.game {
position: relative;
display: inline-block;
height: 60%;
.game img {
cursor: pointer;
.game .safari {
margin-top: 50px;
height: 430.188px;
width: 573.578px;
.game .gazelle {
position: absolute;
top: 260px;
left: 231px;
z-index: 1;
max-height: 50px;
transition-property: max-height;
transition-duration: 750ms;
transition-timing-function: linear;
transition-delay: 400ms;
.game .gazelle:hover {
max-height: 180px;
html,
body {
margin-top: 50px;
height: 100%;
text-align: center;
h1 {
font-size: 40px;
.game {
position: relative;
display: inline-block;
height: 60%;
.game img {
cursor: pointer;
.game .safari {
margin-top: 50px;
height: 430.188px;
width: 573.578px;
.game .gazelle {
position: absolute;
top: 260px;
left: 231px;
z-index: 1;
max-height: 50px;
.game .gazelle:hover {
max-height: 180px;
}
CSS TRANSITIONS
Combinations
The shorthand transition rule has one advantage over the set of
separate transition-<property> rules: you can describe unique transitions for
multiple properties, and combine them.
To combine transitions, add a comma (,) before the semicolon (;) in your rule.
After the comma, use the same shorthand syntax. For example:
Instructions
1.
Let’s try this with a deeper example. Note that some of the CSS used in this
example is out of scope for this lesson; however, we’re confident you’ll have
no trouble transforming the experience of a page with transitions.
When you mouse over the button in the browser, you’ll notice it instantly
changes. Let’s fix this so that the change is animated.
Make a new CSS ruleset in style.css to target all elements within the button.
There are three types of elements to account for, <span>, <div>, and <i>:
.button span,
.button div,
.button i {
}
Hint
Remember the spaces and curly braces!
2.
Within the new ruleset, add a shorthand transition declaration to transition the
width of all elements. Set the property to be transitioned to width, the duration
to 750ms, the timing function to ease-in, and the delay to 200ms.
Stuck? Get a hint
3.
That looks nicer except that the “DOWNLOAD” text disappears instantly. Let’s
animate that in tandem.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Animation All</title>
</head>
<body>
<a class="fancy button" style="color: white;" href="#" role="button">
<span>DOWNLOAD</span>
<div class="icon">
</div>
</a>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/* Main Styles */
body {
min-width: 300px;
background-color: #ecf0f1;
font-size: 16px;
.button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
overflow: hidden;
margin: auto;
border-radius: 5px;
width: 300px;
height: 100px;
line-height: 100px;
background-color: #34B3A0;
color: #fff;
.button span,
.button .icon {
position: absolute;
display: block;
height: 100%;
text-align: center;
.button span {
width: 72%;
left: 0px;
line-height: inherit;
font-size: 22px;
}
.button .icon {
right: 0;
width: 28%;
font-size: 30px;
vertical-align: middle;
.icon {
width: 200px;
background-color: #1A7B72;
.button:hover span {
left: -72%;
.button:hover .icon {
width: 100%;
}
.button:hover .icon .fa {
font-size: 45px;
Learn
CSS TRANSITIONS
Combinations
The shorthand transition rule has one advantage over the set of separate transition-
<property> rules: you can describe unique transitions for multiple properties, and combine them.
To combine transitions, add a comma (,) before the semicolon (;) in your rule. After the comma,
use the same shorthand syntax. For example:
Instructions
1.
Let’s try this with a deeper example. Note that some of the CSS used in this example is out of
scope for this lesson; however, we’re confident you’ll have no trouble transforming the
experience of a page with transitions.
When you mouse over the button in the browser, you’ll notice it instantly changes. Let’s fix this
so that the change is animated.
Make a new CSS ruleset in style.css to target all elements within the button. There are three
types of elements to account for, <span>, <div>, and <i>:
.button span,
.button div,
.button i {
}
Checkpoint 2 Passed
Hint
Within the new ruleset, add a shorthand transition declaration to transition the width of all
elements. Set the property to be transitioned to width, the duration to 750ms, the timing function
to ease-in, and the delay to 200ms.
Checkpoint 3 Passed
3.
That looks nicer except that the “DOWNLOAD” text disappears instantly. Let’s animate that in
tandem.
Hint
The new set of values will go after the first set, separated by a comma.
4.
There’s one more instantaneous change to smooth out: the icon size.
Add another transition to the chain for font-size. Make the duration 950ms and the timing
function linear. Since there is no delay on this transition, leave off the last delay value.
Checkpoint 5 Passed
Hint
Community Forums
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/* Main Styles */
body {
min-width: 300px;
background-color: #ecf0f1;
font-size: 16px;
.button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
overflow: hidden;
margin: auto;
border-radius: 5px;
width: 300px;
height: 100px;
line-height: 100px;
background-color: #34B3A0;
color: #fff;
.button span,
.button .icon {
position: absolute;
display: block;
height: 100%;
text-align: center;
.button span {
width: 72%;
left: 0px;
line-height: inherit;
font-size: 22px;
.button .icon {
right: 0;
width: 28%;
vertical-align: middle;
.button span,
.button div,
.button i {
.icon {
width: 200px;
background-color: #1A7B72;
.button:hover span {
left: -72%;
.button:hover .icon {
width: 100%;
}
.button:hover .icon .fa {
font-size: 45px;
}
All
Even with the shorthand, specifying transitions for many properties can be
tedious. It is common to use the same duration, timing function, and delay for
multiple properties. When this is the case you can set the transition-
property value to all. This will apply the same values to all properties. To effect
this, you can use all as a value for transition-property.
all means every value that changes will be transitioned in the same way. You
can use all with the separate transition properties, or the shorthand syntax.
This allows you to describe the transition of many properties with a single line:
Instructions
1.
Replace all the combined transitions with one single transition for all.
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/* Main Styles */
body {
min-width: 300px;
background-color: #ecf0f1;
font-size: 16px;
.button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
overflow: hidden;
margin: auto;
border-radius: 5px;
width: 300px;
height: 100px;
line-height: 100px;
background-color: #34B3A0;
color: #fff;
.button span,
.button .icon {
position: absolute;
display: block;
height: 100%;
text-align: center;
.button span {
width: 72%;
left: 0px;
line-height: inherit;
font-size: 22px;
.button .icon {
right: 0;
width: 28%;
vertical-align: middle;
.button span,
.button div,
.button i {
.icon {
width: 200px;
background-color: #1A7B72;
.button:hover span {
left: -72%;
.button:hover .icon {
width: 100%;
}
.button:hover .icon .fa {
font-size: 45px;
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/* Main Styles */
body {
min-width: 300px;
background-color: #ecf0f1;
font-size: 16px;
.button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
overflow: hidden;
margin: auto;
border-radius: 5px;
height: 100px;
line-height: 100px;
background-color: #34B3A0;
color: #fff;
.button span,
.button .icon {
position: absolute;
display: block;
height: 100%;
text-align: center;
.button span {
width: 72%;
left: 0px;
line-height: inherit;
font-size: 22px;
.button .icon {
right: 0;
width: 28%;
}
font-size: 30px;
vertical-align: middle;
.button span,
.button div,
.button i {
// transition: width 750ms ease-in 200ms, left 500ms ease-out 450ms, font-size 950ms linear;
.icon {
width: 200px;
background-color: #1A7B72;
.button:hover span {
left: -72%;
.button:hover .icon {
width: 100%;
}
font-size: 45px;
Learn
CSS TRANSITIONS
All
Even with the shorthand, specifying transitions for many properties can be tedious. It is common
to use the same duration, timing function, and delay for multiple properties. When this is the case
you can set the transition-property value to all. This will apply the same values to all
properties. To effect this, you can use all as a value for transition-property.
all means every value that changes will be transitioned in the same way. You can use all with
the separate transition properties, or the shorthand syntax. This allows you to describe the
transition of many properties with a single line:
Instructions
1.
Replace all the combined transitions with one single transition for all.
Hint
You’ll need to remove the existing value sets from the transition property and replace them
with a single shorthand declaration using all 1.2s ease-out, and 0.2s.
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/* Main Styles */
body {
min-width: 300px;
background-color: #ecf0f1;
font-size: 16px;
.button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
overflow: hidden;
margin: auto;
border-radius: 5px;
width: 300px;
height: 100px;
line-height: 100px;
background-color: #34B3A0;
color: #fff;
.button span,
.button .icon {
position: absolute;
display: block;
height: 100%;
text-align: center;
.button span {
width: 72%;
left: 0px;
line-height: inherit;
font-size: 22px;
.button .icon {
right: 0;
width: 28%;
}
.button .icon .fa {
font-size: 30px;
vertical-align: middle;
.button span,
.button div,
.button i {
// transition: width 750ms ease-in 200ms, left 500ms ease-out 450ms, font-size 950ms linear;
.icon {
width: 200px;
background-color: #1A7B72;
.button:hover span {
left: -72%;
.button:hover .icon {
width: 100%;
}
.button:hover .icon .fa {
font-size: 45px;
CSS TRANSITIONS
Review
CSS Transitions are a powerful tool for providing visual feedback to users. We’ve learned
a lot about transitions, so let’s review:
A simple transition can be described with a property and a duration, which can be
written like this:
transition-property: color;
transition-duration: 1s;
Many properties’ state changes can be transitioned, including color, background color,
font size, width, and height. all is also a valid transition property that causes every
changing property to transition.
If you want to learn more about CSS Transitions, we recommend MDN’s Using CSS
Transitions doc.
Good work, you now have the tools to make your web pages come to life!
ADVANCED CSS: FLEXBOX AND CSS TRANSITIONS
Transitions - 20,000 Leagues Under the Sea
In this project you will follow step-by-step instructions to add animations to
an existing static web page. The web page is an online reader; it presents the
full text of the book “20,000 Leagues Under the Sea” by Jules Verne.
The page for the first chapter is mostly complete. There are a few fancy
features:
When you hover over the sidebar on the left, a menu opens which
contains the Table of Contents.
When you hover over a highlighted word in the text, a definition
appears. See the words “phosphorescent” and “locomotion”.
When you hover over the semi-transparent buttons at the bottom of the
page, they turn opaque.
When you hover over any link, it changes color.
If you get stuck during this project or would like to see an experienced
developer work through it, click “Get Unstuck“ to see a project walkthrough
video.
Tasks
0/5 Complete
Mark the tasks as complete by checking them off
1.
In style.css, find the ruleset for links inside the sidebar ( nav a). Add a CSS
declaration to transition the text color. Experiment with different values for
duration, timing function, and delay until you are satisfied.
Hint
Add a shorthand ‘transition’ property starting with a value of color, followed
by any values you choose for duration, timing function, and delay.
Duration and delay values can be specified using seconds or milliseconds, and
examples of a timing functions are ease and linear!
2.
Next, you’ll animate the “Next” and “Back” buttons’ transparency.
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Cormorant+Garamond:500,700,700i"
rel="stylesheet">
</head>
<body>
<nav>
<div class="hover-content">
<h2>Contents</h2>
<h3>PART ONE</h3>
<ol>
</ol>
</div>
<div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-6/triangle.png">
</div>
</nav>
<header class="banner">
<em>by</em>
<h2>Jules Verne</h2>
</header>
<div class="book-content">
<h3>Part One</h3>
<div class="chapter">
<div class="prose">The year 1866 was signalised by a remarkable incident, a mysterious and puzzling
phenomenon, which doubtless no one has yet forgotten. Not to mention rumours which agitated the
maritime population and excited the public mind, even in the interior of continents, seafaring men were
particularly excited. Merchants, common sailors, captains of vessels, skippers, both of Europe and
America, naval officers of all countries, and the Governments of several States on the two continents,
were deeply interested in the matter.</div>
<div class="prose">For some time past vessels had been met by “an enormous thing,” a long object,
spindle-shaped, occasionally
<div class="definable">
--><div class="definition-container">
<h4>phosphorescent</h4>
<ul class="definitions">
<li>Exhibiting a luminescence that is caused by the absorption of radiations (as light or electrons)
and continues for a noticeable time after these radiations have stopped</li>
</ul>
</div><!--
--></div>, and infinitely larger and more rapid in its movements than a whale.</div>
<div class="prose">The facts relating to this apparition (entered in various log-books) agreed in most
respects as to the shape of the object or creature in question, the untiring rapidity of its movements, its
surprising power of
<div class="definable">
<span class="word">locomotion</span><!--
--><div class="definition-container">
<h4>locomotion</h4>
<ol class="definitions">
</ol>
</div><!--
--></div>,
and the peculiar life with which it seemed endowed. If it was a whale, it surpassed in size all those
hitherto classified in science. Taking into consideration the mean of observations made at divers times—
rejecting the timid estimate of those who assigned to this object a length of two hundred feet, equally
with the exaggerated opinions which set it down as a mile in width and three in length—we might fairly
conclude that this mysterious being surpassed greatly all dimensions admitted by the learned ones of
the day, if it existed at all. And that it DID exist was an undeniable fact; and, with that tendency which
disposes the human mind in favour of the marvellous, we can understand the excitement produced in
the entire world by this supernatural apparition. As to classing it in the list of fables, the idea was out of
the question.</div>
<div class="prose">On the 20th of July, 1866, the steamer Governor Higginson, of the Calcutta and
Burnach Steam Navigation Company, had met this moving mass five miles off the east coast of Australia.
Captain Baker thought at first that he was in the presence of an unknown sandbank; he even prepared
to determine its exact position when two columns of water, projected by the mysterious object, shot
with a hissing noise a hundred and fifty feet up into the air. Now, unless the sandbank had been
submitted to the intermittent eruption of a geyser, the Governor Higginson had to do neither more nor
less than with an aquatic mammal, unknown till then, which threw up from its blow-holes columns of
water mixed with air and vapour.</div>
<div class="navigation-buttons">
</div>
</body>
</html>
/* Universal Styles */
html {
font-size: 16px;
body {
min-width: 475px;
html {
font-size: 14px;
html {
font-size: 12px;
}
/* Navigation Bar */
nav {
position: fixed;
z-index: 5;
left: -17.8em;
display: flex;
align-items: center;
height: 100%;
padding-left: 5rem;
padding-right: 2rem;
background: url("https://content.codecademy.com/courses/freelance-1/unit-6/nav_background.png")
center center repeat;
font-size: 18px;
line-height: 2.2;
font-weight: bold;
color: #142033;
nav:hover {
left: 0;
}
nav .hover-content {
margin-right: 3em;
nav h2 {
font-size: 2.6em;
font-weight: bold;
color: #639eff;
nav h3 {
padding-bottom: 1.1em;
nav ol {
nav a {
text-decoration: none;
color: inherit;
}
nav a:hover,
nav a.active {
color: #639eff;
/* Header */
header {
background-color: #142033;
text-align: center;
font-weight: bold;
line-height: 2.1;
color: #b3d0ff;
header h1 {
font-size: 6rem;
line-height: 1;
font-weight: 500;
color: #66a1ff;
}
header em {
font-size: 1.5rem;
font-style: italic;
header h2 {
font-size: 3rem;
header {
header h1 {
font-size: 4rem;
header h2 {
font-size: 2rem;
/* Book Content */
.book-content {
background-color: #f2f7ff;
font-size: 1.5rem;
line-height: 2;
color: #4a4a4a;
cursor: default;
.book-content h3 {
text-align: center;
font-size: 3rem;
line-height: 2.1;
font-weight: bold;
color: #142033;
.chapter {
color: #639eff;
.chapter .number {
display: block;
font-size: 1.25rem;
}
.chapter .name {
display: block;
font-size: 2.25rem;
.book-content .prose {
margin-bottom: 4.75rem;
.book-content {
padding-right: 10%;
.book-content {
padding-right: 1%;
/* Word Definitions */
.definable {
display: inline;
.definable .word {
color: #639eff;
.definable .word:hover {
color: #306acc;
.definable .definition-container {
position: fixed;
z-index: 10;
top: -100%;
left: 0;
box-sizing: border-box;
width: 100%;
background-color: #ffffff;
opacity: 0;
.definable:hover .definition-container {
top: 0;
opacity: 1;
.definition-container h4 {
font-size: 3rem;
font-weight: bold;
line-height: 2.1;
color: #66a1ff;
.definition-container .information {
display: block;
line-height: 2.5;
color: #9b9b9b;
.definition-container .definitions {
color: #4a4a4a;
.navigation-buttons {
display: flex;
justify-content: space-between;
align-items: center;
.button {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 13rem;
padding: 0 2rem;
background-color: #639eff;
opacity: 0.3;
font-size: 3rem;
font-weight: bold;
text-decoration: none;
color: #ffffff;
}
.button:hover {
opacity: 1;
.button {
width: auto;
.button .action {
display: none;
/* Universal Styles */
html {
font-size: 16px;
body {
min-width: 475px;
html {
font-size: 14px;
html {
font-size: 12px;
/* Navigation Bar */
nav {
position: fixed;
z-index: 5;
left: -17.8em;
display: flex;
align-items: center;
height: 100%;
padding-left: 5rem;
padding-right: 2rem;
background: url("https://content.codecademy.com/courses/freelance-1/unit-6/nav_background.png")
center center repeat;
font-size: 18px;
line-height: 2.2;
font-weight: bold;
color: #142033;
transition-property:left;
transition-duration:1s;
transition-timing-function:1s;
transition-delay:1s;
nav:hover {
left: 0;
nav .hover-content {
margin-right: 3em;
nav h2 {
font-size: 2.6em;
font-weight: bold;
color: #639eff;
nav h3 {
padding-bottom: 1.1em;
nav ol {
nav a {
text-decoration: none;
color: inherit;
transition-property:color;
transition-duration:800ms;
transition-timing-function:ease-in;
transition-delay:300ms;
nav a:hover,
nav a.active {
color: #639eff;
}
/* Header */
header {
background-color: #142033;
text-align: center;
font-weight: bold;
line-height: 2.1;
color: #b3d0ff;
header h1 {
font-size: 6rem;
line-height: 1;
font-weight: 500;
color: #66a1ff;
header em {
font-size: 1.5rem;
font-style: italic;
header h2 {
font-size: 3rem;
header {
header h1 {
font-size: 4rem;
header h2 {
font-size: 2rem;
/* Book Content */
.book-content {
background-color: #f2f7ff;
font-size: 1.5rem;
line-height: 2;
color: #4a4a4a;
cursor: default;
.book-content h3 {
text-align: center;
font-size: 3rem;
line-height: 2.1;
font-weight: bold;
color: #142033;
.chapter {
color: #639eff;
.chapter .number {
display: block;
font-size: 1.25rem;
.chapter .name {
display: block;
font-size: 2.25rem;
}
.book-content .prose {
margin-bottom: 4.75rem;
.book-content {
padding-right: 10%;
.book-content {
padding-right: 1%;
/* Word Definitions */
.definable {
display: inline;
.definable .word {
color: #639eff;
}
.definable .word:hover {
color: #306acc;
.definable .definition-container {
position: fixed;
z-index: 10;
top: -100%;
left: 0;
box-sizing: border-box;
width: 100%;
background-color: #ffffff;
opacity: 0;
font-size: 1.5rem;
.definable:hover .definition-container {
top: 0;
opacity: 1;
.definition-container h4 {
font-size: 3rem;
font-weight: bold;
line-height: 2.1;
color: #66a1ff;
.definition-container .information {
display: block;
line-height: 2.5;
color: #9b9b9b;
.definition-container .definitions {
line-height: 1.7;
color: #4a4a4a;
display: flex;
justify-content: space-between;
align-items: center;
.button {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 13rem;
padding: 0 2rem;
background-color: #639eff;
opacity: 0.3;
font-size: 3rem;
font-weight: bold;
text-decoration: none;
color: #ffffff;
transition-property:opacity;
transition-duration:500ms;
transition-timing-function:ease-in-out;
transition-delay:300ms;
.button:hover {
opacity: 1;
.button {
width: auto;
.button .action {
display: none;
/* Universal Styles */
html {
font-size: 16px;
body {
min-width: 475px;
font-size: 14px;
html {
font-size: 12px;
/* Navigation Bar */
nav {
position: fixed;
z-index: 5;
left: -17.8em;
display: flex;
align-items: center;
height: 100%;
padding-left: 5rem;
padding-right: 2rem;
background: url("https://content.codecademy.com/courses/freelance-1/unit-6/nav_background.png")
center center repeat;
line-height: 2.2;
font-weight: bold;
color: #142033;
transition-property:left;
transition-duration:1s;
transition-timing-function:1s;
transition-delay:1s;
nav:hover {
left: 0;
nav .hover-content {
margin-right: 3em;
nav h2 {
font-size: 2.6em;
font-weight: bold;
color: #639eff;
}
nav h3 {
padding-bottom: 1.1em;
nav ol {
nav a {
text-decoration: none;
color: inherit;
transition-property:color;
transition-duration:800ms;
transition-timing-function:ease-in;
transition-delay:300ms;
nav a:hover,
nav a.active {
color: #639eff;
/* Header */
header {
background-color: #142033;
text-align: center;
font-weight: bold;
line-height: 2.1;
color: #b3d0ff;
header h1 {
font-size: 6rem;
line-height: 1;
font-weight: 500;
color: #66a1ff;
header em {
font-size: 1.5rem;
font-style: italic;
header h2 {
font-size: 3rem;
}
@media only screen and (max-width: 810px) {
header {
header h1 {
font-size: 4rem;
header h2 {
font-size: 2rem;
/* Book Content */
.book-content {
background-color: #f2f7ff;
font-size: 1.5rem;
line-height: 2;
color: #4a4a4a;
cursor: default;
}
.book-content h3 {
text-align: center;
font-size: 3rem;
line-height: 2.1;
font-weight: bold;
color: #142033;
.chapter {
color: #639eff;
.chapter .number {
display: block;
font-size: 1.25rem;
.chapter .name {
display: block;
font-size: 2.25rem;
.book-content .prose {
margin-bottom: 4.75rem;
}
.book-content {
padding-right: 10%;
.book-content {
padding-right: 1%;
/* Word Definitions */
.definable {
display: inline;
.definable .word {
color: #639eff;
transition-property:color:
transition-duration:300ms;
transition-timing-function:ease-in;
}
.definable .word:hover {
color: #306acc;
.definable .definition-container {
position: fixed;
z-index: 10;
top: -100%;
left: 0;
box-sizing: border-box;
width: 100%;
background-color: #ffffff;
opacity: 0;
font-size: 1.5rem;
transition-property:top,opacity:
transition-duration:2000ms,3000ms;
transition-delay:0s,1000ms;
}
.definable:hover .definition-container {
top: 0;
opacity: 1;
.definition-container h4 {
font-size: 3rem;
font-weight: bold;
line-height: 2.1;
color: #66a1ff;
.definition-container .information {
display: block;
line-height: 2.5;
color: #9b9b9b;
.definition-container .definitions {
line-height: 1.7;
color: #4a4a4a;
}
.navigation-buttons {
display: flex;
justify-content: space-between;
align-items: center;
.button {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 13rem;
padding: 0 2rem;
background-color: #639eff;
opacity: 0.3;
font-size: 3rem;
font-weight: bold;
text-decoration: none;
color: #ffffff;
transition-property:opacity;
transition-duration:500ms;
transition-timing-function:ease-in-out;
transition-delay:300ms;
.button:hover {
opacity: 1;
.button {
width: auto;
.button .action {
display: none;
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Cormorant+Garamond:500,700,700i"
rel="stylesheet">
<body>
<nav>
<div class="hover-content">
<h2>Contents</h2>
<h3>PART ONE</h3>
<ol>
</ol>
</div>
<div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-6/triangle.png">
</div>
</nav>
<em>by</em>
<h2>Jules Verne</h2>
</header>
<div class="book-content">
<h3>Part One</h3>
<div class="chapter">
</div>
<div class="prose">The year 1866 was signalised by a remarkable incident, a mysterious and puzzling
phenomenon, which doubtless no one has yet forgotten. Not to mention rumours which agitated the
maritime population and excited the public mind, even in the interior of continents, seafaring men were
particularly excited. Merchants, common sailors, captains of vessels, skippers, both of Europe and
America, naval officers of all countries, and the Governments of several States on the two continents,
were deeply interested in the matter.</div>
<div class="prose">For some time past vessels had been met by “an enormous thing,” a long object,
spindle-shaped, occasionally
<div class="definable">
--><div class="definition-container">
<h4>phosphorescent</h4>
<span class="information">adjective | phos·pho·res·cent</span>
<ul class="definitions">
<li>Exhibiting a luminescence that is caused by the absorption of radiations (as light or electrons)
and continues for a noticeable time after these radiations have stopped</li>
</ul>
</div><!--
--></div>, and infinitely larger and more rapid in its movements than a whale.</div>
<div class="prose">The facts relating to this apparition (entered in various log-books) agreed in most
respects as to the shape of the object or creature in question, the untiring rapidity of its movements, its
surprising power of
<div class="definable">
<span class="word">locomotion</span><!--
--><div class="definition-container">
<h4>locomotion</h4>
<ol class="definitions">
</ol>
</div><!--
--></div>,
and the peculiar life with which it seemed endowed. If it was a whale, it surpassed in size all those
hitherto classified in science. Taking into consideration the mean of observations made at divers times—
rejecting the timid estimate of those who assigned to this object a length of two hundred feet, equally
with the exaggerated opinions which set it down as a mile in width and three in length—we might fairly
conclude that this mysterious being surpassed greatly all dimensions admitted by the learned ones of
the day, if it existed at all. And that it DID exist was an undeniable fact; and, with that tendency which
disposes the human mind in favour of the marvellous, we can understand the excitement produced in
the entire world by this supernatural apparition. As to classing it in the list of fables, the idea was out of
the question.</div>
<div class="prose">On the 20th of July, 1866, the steamer Governor Higginson, of the Calcutta and
Burnach Steam Navigation Company, had met this moving mass five miles off the east coast of Australia.
Captain Baker thought at first that he was in the presence of an unknown sandbank; he even prepared
to determine its exact position when two columns of water, projected by the mysterious object, shot
with a hissing noise a hundred and fifty feet up into the air. Now, unless the sandbank had been
submitted to the intermittent eruption of a geyser, the Governor Higginson had to do neither more nor
less than with an aquatic mammal, unknown till then, which threw up from its blow-holes columns of
water mixed with air and vapour.</div>
<div class="navigation-buttons">
</div>
</div>
</body>
</html>
The page for the first chapter is mostly complete. There are a few fancy
features:
When you hover over the sidebar on the left, a menu opens which
contains the Table of Contents.
When you hover over a highlighted word in the text, a definition
appears. See the words “phosphorescent” and “locomotion”.
When you hover over the semi-transparent buttons at the bottom of the
page, they turn opaque.
When you hover over any link, it changes color.
If you get stuck during this project or would like to see an experienced
developer work through it, click “Get Unstuck“ to see a project walkthrough
video.
Tasks
5/5 Complete
Mark the tasks as complete by checking them off
1.
In style.css, find the ruleset for links inside the sidebar ( nav a). Add a CSS
declaration to transition the text color. Experiment with different values for
duration, timing function, and delay until you are satisfied.
Hint
Add a shorthand ‘transition’ property starting with a value of color, followed
by any values you choose for duration, timing function, and delay.
Duration and delay values can be specified using seconds or milliseconds, and
examples of a timing functions are ease and linear!
2.
Next, you’ll animate the “Next” and “Back” buttons’ transparency.
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Cormorant+Garamond:500,700,700i"
rel="stylesheet">
</head>
<body>
<nav>
<div class="hover-content">
<h2>Contents</h2>
<h3>PART ONE</h3>
<ol>
</ol>
</div>
<div>
<img src="https://content.codecademy.com/courses/freelance-1/unit-6/triangle.png">
</div>
</nav>
<header class="banner">
<em>by</em>
<h2>Jules Verne</h2>
</header>
<div class="book-content">
<h3>Part One</h3>
<div class="chapter">
</div>
<div class="prose">The year 1866 was signalised by a remarkable incident, a mysterious and puzzling
phenomenon, which doubtless no one has yet forgotten. Not to mention rumours which agitated the
maritime population and excited the public mind, even in the interior of continents, seafaring men were
particularly excited. Merchants, common sailors, captains of vessels, skippers, both of Europe and
America, naval officers of all countries, and the Governments of several States on the two continents,
were deeply interested in the matter.</div>
<div class="prose">For some time past vessels had been met by “an enormous thing,” a long object,
spindle-shaped, occasionally
<div class="definable">
<span class="word">phosphorescent</span><!-- Trailing comments prevents indentation whitespace
from displaying between divs.
--><div class="definition-container">
<h4>phosphorescent</h4>
<ul class="definitions">
<li>Exhibiting a luminescence that is caused by the absorption of radiations (as light or electrons)
and continues for a noticeable time after these radiations have stopped</li>
</ul>
</div><!--
--></div>, and infinitely larger and more rapid in its movements than a whale.</div>
<div class="prose">The facts relating to this apparition (entered in various log-books) agreed in most
respects as to the shape of the object or creature in question, the untiring rapidity of its movements, its
surprising power of
<div class="definable">
<span class="word">locomotion</span><!--
--><div class="definition-container">
<h4>locomotion</h4>
<ol class="definitions">
</ol>
</div><!--
--></div>,
and the peculiar life with which it seemed endowed. If it was a whale, it surpassed in size all those
hitherto classified in science. Taking into consideration the mean of observations made at divers times—
rejecting the timid estimate of those who assigned to this object a length of two hundred feet, equally
with the exaggerated opinions which set it down as a mile in width and three in length—we might fairly
conclude that this mysterious being surpassed greatly all dimensions admitted by the learned ones of
the day, if it existed at all. And that it DID exist was an undeniable fact; and, with that tendency which
disposes the human mind in favour of the marvellous, we can understand the excitement produced in
the entire world by this supernatural apparition. As to classing it in the list of fables, the idea was out of
the question.</div>
<div class="prose">On the 20th of July, 1866, the steamer Governor Higginson, of the Calcutta and
Burnach Steam Navigation Company, had met this moving mass five miles off the east coast of Australia.
Captain Baker thought at first that he was in the presence of an unknown sandbank; he even prepared
to determine its exact position when two columns of water, projected by the mysterious object, shot
with a hissing noise a hundred and fifty feet up into the air. Now, unless the sandbank had been
submitted to the intermittent eruption of a geyser, the Governor Higginson had to do neither more nor
less than with an aquatic mammal, unknown till then, which threw up from its blow-holes columns of
water mixed with air and vapour.</div>
<div class="navigation-buttons">
</div>
</div>
</body>
</html>
/* Universal Styles */
html {
font-size: 16px;
}
body {
min-width: 475px;
html {
font-size: 14px;
html {
font-size: 12px;
/* Navigation Bar */
nav {
position: fixed;
z-index: 5;
left: -17.8em;
display: flex;
align-items: center;
height: 100%;
padding-left: 5rem;
padding-right: 2rem;
background: url("https://content.codecademy.com/courses/freelance-1/unit-6/nav_background.png")
center center repeat;
font-size: 18px;
line-height: 2.2;
font-weight: bold;
color: #142033;
transition-property:left;
transition-duration:1s;
transition-timing-function:1s;
transition-delay:1s;
nav:hover {
left: 0;
nav .hover-content {
margin-right: 3em;
}
nav h2 {
font-size: 2.6em;
font-weight: bold;
color: #639eff;
nav h3 {
padding-bottom: 1.1em;
nav ol {
nav a {
text-decoration: none;
color: inherit;
transition-property:color;
transition-duration:800ms;
transition-timing-function:ease-in;
transition-delay:300ms;
}
nav a:hover,
nav a.active {
color: #639eff;
/* Header */
header {
background-color: #142033;
text-align: center;
font-weight: bold;
line-height: 2.1;
color: #b3d0ff;
header h1 {
font-size: 6rem;
line-height: 1;
font-weight: 500;
color: #66a1ff;
header em {
font-size: 1.5rem;
font-style: italic;
header h2 {
font-size: 3rem;
header {
header h1 {
font-size: 4rem;
header h2 {
font-size: 2rem;
/* Book Content */
.book-content {
padding: 4.75rem 20%;
background-color: #f2f7ff;
font-size: 1.5rem;
line-height: 2;
color: #4a4a4a;
cursor: default;
.book-content h3 {
text-align: center;
font-size: 3rem;
line-height: 2.1;
font-weight: bold;
color: #142033;
.chapter {
color: #639eff;
.chapter .number {
display: block;
font-size: 1.25rem;
}
.chapter .name {
display: block;
font-size: 2.25rem;
.book-content .prose {
margin-bottom: 4.75rem;
.book-content {
padding-right: 10%;
.book-content {
padding-right: 1%;
/* Word Definitions */
.definable {
display: inline;
.definable .word {
color: #639eff;
transition-property:color:
transition-duration:300ms;
transition-timing-function:ease-in;
.definable .word:hover {
color: #306acc;
.definable .definition-container {
position: fixed;
z-index: 10;
top: -100%;
left: 0;
box-sizing: border-box;
width: 100%;
background-color: #ffffff;
box-shadow: 0 0 64px 0 rgba(0, 0, 0, 0.2);
opacity: 0;
font-size: 1.5rem;
transition-property:top,opacity:
transition-duration:2000ms,3000ms;
transition-delay:0s,1000ms;
.definable:hover .definition-container {
top: 0;
opacity: 1;
.definition-container h4 {
font-size: 3rem;
font-weight: bold;
line-height: 2.1;
color: #66a1ff;
.definition-container .information {
display: block;
line-height: 2.5;
color: #9b9b9b;
.definition-container .definitions {
line-height: 1.7;
color: #4a4a4a;
.navigation-buttons {
display: flex;
justify-content: space-between;
align-items: center;
.button {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 13rem;
padding: 0 2rem;
background-color: #639eff;
opacity: 0.3;
font-size: 3rem;
font-weight: bold;
text-decoration: none;
color: #ffffff;
transition-property:opacity;
transition-duration:500ms;
transition-timing-function:ease-in-out;
transition-delay:300ms;
.button:hover {
opacity: 1;
.button {
width: auto;
.button .action {
display: none;
}
Fontawesome:
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
</div>
</body>
</html>
FONT AWESOME
Introduction to Font Awesome
Icons are small symbols used on many websites to convey information, often without
text. Most people associate a few commonly used icons with specific software actions.
For example, the floppy disk icon is commonly associated with saving a document —
years after we’ve stopped using floppy disks! In this lesson, we will introduce Font
Awesome, a library used to add widely recognized icons to web pages. We will walk you
through the two simple steps required to add a Font Awesome icon:
When used correctly, these icons save space, appear cleaner than text, and make
common actions stand out to the user.
By the end of this lesson, you will know how to add, position, and size Font Awesome
icons on a web page.
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h1>WELCOME TO OUR SURVEY!</h1>
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<div id="question3" class="question">
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<!-- Social Media Icons -->
<div class="social">
</div>
</body>
</html>
https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/fontawesome.min.css
FONT AWESOME
<head>
<link rel="stylesheet" type="text/css"
href="https://stackpath.bootstrapcdn.com/font-
awesome/4.7.0/css/font-awesome.min.css">
</head>
In the example above, the <link> tag is used to reference (href) font-
awesome.css, stored on a Bootstrap CDN server. The rel and type values
indicate the file is a CSS stylesheet.
When linking to a local version of Font Awesome, you should download the
most up-to-date file. The Font Awesome css file can then be added to the
current project directory. The <link> tag is used to reference the Font
Awesome CSS file.
<head>
<link rel="stylesheet" type="text/css"
href="resources/css/font-awesome.css">
</head>
In the example above, a local version of Font Awesome is linked in the head of
the HTML document. The href value is a path to the local Font Awesome CSS
file. The css folder in the downloaded font-awesome-4.7.0 directory was
dragged into resources, a local directory for storing additional styling
resources. Notice the rest of the path, css/font-awesome.css, is the same as the
CDN.
Both methods are acceptable. The CDN method is faster and requires less
storage space, while the locally stored library will work in the event that the
CDN server goes down and allows you the flexibility to edit your website even
when you don’t have internet access.
Instructions
1.
Link the following path in the <head> of the HTML file. It is a path to the local
Font Awesome CSS file.
resources/css/font-awesome.css
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
<span>Share your results with friends</span>
</div>
</body>
</html>
https://fontawesome.com/start
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<!-- Social Media Icons -->
<div class="social">
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
</div>
</body>
</html>
FONT AWESOME
Font Awesome icons are saved as CSS classes. They are placed into an HTML
document by adding an <i> tag with two classes: fa and fa-icon-name,
where fa-icon-name refers to the icon-specific class name.
Instructions
1.
Under the twitter icon, use the cheat sheet to add the pinterest icon.
FONT AWESOME
Font Awesome icons are saved as CSS classes. They are placed into an HTML
document by adding an <i> tag with two classes: fa and fa-icon-name,
where fa-icon-name refers to the icon-specific class name.
Use the Font Awesome cheat sheet to find Font Awesome icons and their
matching classes.
Instructions
1.
2.
3.
Under the twitter icon, use the cheat sheet to add the pinterest icon.
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<div id="question2" class="question">
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
</div>
</body>
</html>
FONT AWESOME
Icon Sizing
Font Awesome supports additional classes for icon sizing.
Icon size can be increased by 33% with fa-lg, two times with fa-2x, three times
with fa-3x, four times with fa-4x, or five times with fa-5x.
Instructions
1.
Make each of the social media icons 33% larger.
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Please Participate in Our Survey!</title>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round:100,400"
rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
</ul>
</nav>
<div class="welcome">
<h3>We're looking forward to getting your answers so we can make sure our products and services
are the best they can be!</h3>
</div>
</header>
<!-- Questions -->
<div class="questions">
<h4>QUESTION 1</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 2</h4>
<span class="prompt">I try to keep up to date with the latest fashion in active wear.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 3</h4>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 4</h4>
<span class="prompt">I try to buy goods that are designed and/or manufactured in my home
country.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
<h4>QUESTION 5</h4>
<span class="prompt">I look to famous athletes when trying to choose what to wear when
training.</span>
<span class="answer">DISAGREE</span>
<span class="answer">NEUTRAL</span>
<span class="answer">AGREE</span>
</div>
</div>
<div class="social">
</div>
</body>
</html>
FONT AWESOME
Review
In this lesson, we covered the basics of the Font Awesome icon library. The
library contains a large selection of icons with additional classes for sizing,
listing, and animating.
Although the library provides a large supply of icons and tools, it’s important
to understand that few icons are truly universal. Here are a few best practices
to help you anticipate and plan for user misunderstanding:
1. Research the icon in question. When in doubt, check to see if the icon
shows up on other popular sites.
2. Use a word or two next to the icon for additional context.
Let’s take a minute to review some of the concepts from this lesson:
Take a few moments to look over the content in the workspace to the right.
Try to adjust some of the following:
Use the Font Awesome icon cheat sheet and examples if you need help.
https://fontawesome.com/v5/cheatsheet
https://www.codecademy.com/paths/learn-how-to-build-websites/tracks/finishing-touches-and-
publishing-a-website/modules/finishing-touches/articles/f1-u7a1-managing-assets
https://image.online-convert.com/convert-to-svg
https://www.codecademy.com/learn/paths/learn-how-to-build-websites/tracks/finishing-touches-and-
publishing-a-website/modules/git-and-publishing-to-github-pages/cheatsheet
$ git init
$ git init
$ git status
On branch master
Initial commit
Untracked files:
init_test.rb
scene-1.txt
nothing added to commit but untracked files present (use "git add" to track)
$ scene-1.txt
$ git status
On branch master
Initial commit
Untracked files:
add_test.rb
init_test.rb
scene-1.txt
nothing added to commit but untracked files present (use "git add" to track)
$ ^C
$ ^Mgit status
$ git status
On branch master
Initial commit
Untracked files:
add_test.rb
init_test.rb
scene-1.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git status
On branch master
Initial commit
Changes to be committed:
Untracked files:
init_test.rb
Imagine that we type another line in scene-1.txt. Since the file is tracked, we can check the
differences between the working directory and the staging area with:
Instructions
1.
In the code editor, add this text to scene-1.txt:
2.
From the terminal, use the new command to check the difference between the working directory
and the staging area.
“Harry Programmer and the Sorcerer’s Code: Scene 1” is in the staging area, as
indicated in white.
Changes to the file are marked with a + and are indicated in green.
Checkpoint 3 Passed
Hint
If you get stuck in “diff mode”, press q on your keyboard to exit.
3.
Add the changes to the staging area in Git. Recall that you will need to identify the file by its
name.
Checkpoint 4 Passed
Hint
We can add a file to the staging area with:
Learn
git commit
A commit is the last step in our Git workflow. A commit permanently stores changes from the
staging area inside the repository.
git commit isthe command we’ll do next. However, one more bit of code is needed for a
commit: the option -m followed by a message. Here’s an example:
Instructions
1.
Make your first commit! From the terminal, type the command along with a commit message.
The message should describe the point of the commit.
If you’re having trouble thinking of a good commit message, reflect on how the project has
changed since it began.
ASIC GIT WORKFLOW
git log
Often with Git, you’ll need to refer back to an earlier version of a project.
Commits are stored chronologically in the repository and can be viewed with:
git log
Instructions
1.
From the terminal, log a list of your commits.
Hint
Here’s what an example log looks like:
Instructions
Instructions
https://content.codecademy.com/programs/freelance-one/excursion/index.html
https://content.codecademy.com/programs/freelance-one/excursion/mocks/excursion.png
https://content.codecademy.com/programs/freelance-one/excursion/mocks/excursion_redline.png
https://youtu.be/smYRUiwf8yI
https://www.codecademy.com/paths/learn-how-to-build-websites/tracks/learn-how-to-build-websites-
capstone-project/modules/colmar-academy/informationals/capstone-project-introduction-colmar-
academy
https://content.codecademy.com/courses/freelance-1/capstone-2/colmar-academy-spec.png
<!DOCTYPE
html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./resources/css/reset.css">
<link rel="stylesheet" type="text/css" href="./resources/css/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|
Roboto:400,700" rel="stylesheet">
<title>Colmar Academy</title>
<link rel="icon" href="./resources/images/ic-logo.ico">
</head>
<body>
<!-- School Header -->
<header>
<div class="logo">
<img src="./resources/images/ic-logo.svg" alt="School logo">
<h3 class="title-bar"><span>COLMAR</span>ACADEMY</h3>
</div>
<nav class="desktop">
<a href="#">On Campus</a>
<a href="#">Online</a>
<a href="#">Companies</a>
<a href="#">Sign in</a>
</nav>
<nav class="mobile">
<img src="./resources/images/ic-logo.svg" alt="">
<a href="#"><img src="./resources/images/ic-on-campus.svg" alt="Campus
programs"></a>
<a href="#"><img src="./resources/images/ic-online.svg" alt="Online
programs"></a>
<a href="#"><img src="./resources/images/ic-login.svg" alt="Log in"></a>
</nav>
</header>
<!-- Main Section -->
<main>
<!-- Start Banner -->
<section class="landing-box">
<img src="./resources/images/banner.jpg" alt="Three classmates studying
outside">
<div class="side-text">
<h1>Learn something new everyday</h1>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h3>
<a href="#" class="start">Start here</a>
</div>
</section>
<!-- Campus -->
<section class="information">
<div class="multi-container">
<div class="main-pic-box">
<img src="./resources/images/information-main.jpg" alt="Student
enjoying book outside">
<h2>It doesn't hurt to keep practicing</h2>
<p>"Curabitur vitae libero ipsum porttior consequat. Aliquam et
commodo
lectus, nec consequat neque. Sed non accumsan urna. Phasellus sed
consequat ex. Etiam eget magna laoreet efficitur dolo consequat,
tristique ligula."</p>
<h5>Emaunuel, Sr Strategist at Hiring.com</h5>
</div>
<div class="stacked-content-box">
<div class="content-box">
<img id="pc-pic" src="./resources/images/information-
orientation.jpg" alt="Bird's eye view of orientation" title="">
<img id="mobile-pic" src="./resources/images/information-
orientation-mobile.jpg" alt="Bird's eye view of orientation">
<div class="side-text">
<h3>Orientation Date</h3>
<p>Tue 10/11 & Wed 10/12: 8am-3pm</p>
<a href="#">Read more</a>
</div>
</div>
<div class="content-box">
<img id="pc-pic" src="./resources/images/information-campus.jpg"
alt="Indoors look at common area" title="" style="">
<img id="mobile-pic" src="./resources/images/information-campus-
mobile.jpg" alt="Indoors look at common area">
<div class="side-text">
<h3>Our campus</h3>
<p>Find a campus near you</p>
<a href="#">Read more</a>
</div>
</div>
<div class="content-box">
<img id="pc-pic" src="./resources/images/information-guest-
lecture.jpg" alt="Oliver Sacks" title="" style="">
<img id="mobile-pic" src="./resources/images/information-guest-
lecture-mobile.jpg" alt="Oliver Sacks">
<div class="side-text">
<h3>Our guest lecture</h3>
<p>Join a keynote with Oliver Sacks about music in medical
treatment</p>
<a href="#">Read more</a>
</div>
</div>
</div>
</div>
</section>
<!-- Classes Section -->
<section class="courses">
<h2>Start learning</h2>
<div class="course-container">
<div class="course-box">
<img src="./resources/images/course-software.jpg" alt="Desk with
monitors">
<div class="course-text">
<h3>Software Engineering</h3>
<p>COURSES</p>
<p>Web Development, Mobile Development, IoT, APIs</p>
</div>
</div>
<div class="course-box">
<img src="./resources/images/course-computer-art.jpg" alt="Hand
holding mobile phone">
<div class="course-text">
<h3>Computer Art</h3>
<p>COURSES</p>
<p>Imaging & Design, Web Design, Motion Graphics & Visual
Effects, Computer Animation</p>
</div>
</div>
<div class="course-box">
<img src="./resources/images/course-design.jpg" alt="Person holding
advanced camera">
<div class="course-text">
<h3>Design</h3>
<p>COURSES</p>
<p>User Experience Design, User Research, Visual Design</p>
</div>
</div>
<div class="course-box">
<img src="./resources/images/course-data.jpg" alt="Laptop open with
charts">
<div class="course-text">
<h3>Data</h3>
<p>COURSES</p>
<p>Data Science, Big Data, SQL, Data Visualization</p>
</div>
</div>
<div class="course-box">
<img src="./resources/images/course-business.jpg" alt="Chessboard with
chess pieces">
<div class="course-text">
<h3>Business</h3>
<p>COURSES</p>
<p>Product Development, Business Development, Startup</p>
</div>
</div>
<div class="course-box">
<img src="./resources/images/course-marketing.jpg" alt="Person using
smart watch">
<div class="course-text">
<h3>Marketing</h3>
<p>COURSES</p>
<p>Analytics, Content Marketing, Mobile Marketing</p>
</div>
</div>
</div>
</section>
<!-- Thesis Section -->
<section class="thesis">
<h2>Thesis Exhibits</h2>
<div class="multi-container">
<div class="main-pic-box">
<video src="./resources/videos/thesis.mp4" autoplay muted loop
alt="Shadows on building as time passes"></video>
<h3>Reimagine Urban</h3>
<p>"Curabitur vitae libero ipsum porttior consequat. Aliquam et
commodo
lectus, nec consequat neque. Sed non accumsan urna. Phasellus sed
consequat ex. Etiam eget magna laoreet efficitur dolo consequat,
tristique ligula."</p>
</div>
<div class="stacked-content-box">
<div class="content-box">
<img src="./resources/images/thesis-fisma.jpg" alt="Planning with
highlighter" title="" style="">
<div class="side-text">
<h3>FISMA: Design and Security</h3>
<p>Designer showcase of new prototype project</p>
</div>
</div>
<div class="content-box">
<img src="./resources/images/thesis-now-and-then.jpg" alt="City
skyline" title="" style="">
<div class="side-text">
<h3>Now and Then</h3>
<p>Research study about New York</p>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer Section -->
<footer>
<h5>© 2016 Colmar Academy. All rights reserved</h5>
<nav class="legal">
<span>Terms</span>
<span>Privacy</span>
</nav>
</footer>
</body>
</html>
/* Universal Styles */
html {
font-family: "Open Sans", sans-serif;
font-size: 16px;
color: #01161E;
}
main {
font-family: "Open Sans", sans-serif;
position:relative; /* handle fixed menu bar */
top: 4rem;
color: #01161E;
}
section:nth-child(2n+1) {
background-color: #EEF9ED;
}
section {
width: auto 0;
}
a {
font-family: "Open Sans", sans-serif;
text-decoration: none;
padding-left: 1rem;
color: #01161E;
font-size: 1.25rem;
}
h1 {
font-family: "Roboto", sans-serif;
font-size: 3rem;
font-weight: 900;
line-height: 1.1;
}
h2 {
font-family: "Roboto", sans-serif;
font-size: 2.4rem;
font-weight: bold;
padding: 2rem 0;
}
h3 {
font-family: "Roboto", sans-serif;
font-size: 1.4rem;
line-height: 1.2;
font-weight: bold;
}
h5, footer span {
font-size: 0.8rem;
color: #01161E;
}
p {
line-height: 1.35;
padding: 0.5rem 0.5rem 0.5rem 0;
}
/* Header Section */
header {
background-color: white;
height: 4rem;
width: 100%;
display: flex;
justify-content: space-between;
position: fixed;
z-index: 10;
}
header img {
height: 3rem;
padding: 0 2% 0 1.5rem;
}
.logo {
display: flex;
justify-content: space-between;
align-items: center;
}
.title-bar {
color: #8A97A8;
}
.title-bar span {
padding: 0;
font-weight: bold;
color: #01161E;
}
/* Navigation */
nav {
padding-right: 3%;
align-self: center;
display: flex;
}
.desktop {
display: inline-block;
}
.mobile {
display: none;
}
/* Start Banner */
.side-text {
display: inline-flex;
flex-flow: column;
justify-content: space-between;
vertical-align: middle;
}
.landing-box img {
display: inline-block;
vertical-align: middle;
width: 60%;
margin: 2rem 2.5rem 2rem 1.5rem;
flex-shrink: 0;
}
.landing-box h3 {
margin: 1.5rem 0;
}
.landing-box .side-text {
width: 30%;
box-sizing: border-box;
}
.landing-box p, .main-pic-box p {
margin-bottom: 1.5rem;
}
/* Start Here Button */
.start {
width: 75%;
background-color: #ADBED3;
color: #01161E;
font-size: 1.2rem;
padding: 1rem 0;
text-align: center;
transition:color 400ms, background-color 400ms;
font-weight: bold;
}
.start:hover {
background-color: #FF7954;
color: #01161E;
}
.information .content-box:last-child, .thesis .content-box:first-child
{
background-color: #EEF9ED;
}
/* Large Containers */
.multi-container {
width: 100%;
display: flex;
flex-wrap: nowrap;
}
.main-pic-box {
width: 60%;
padding: 2rem 1.5rem;
}
.main-pic-box img, video {
width: 100%;
margin-bottom: 2rem;
}
.main-pic-box h2 {
padding: 0 0 1.5rem 0;
}
#mobile-pic {
display: none;
}
/* Small Containers*/
.stacked-content-box {
display: flex;
flex-flow: column;
vertical-align: top;
margin-top: 1rem;
width: 35%;
}
.content-box img {
width: 35%;
margin: 3.5%;
vertical-align: middle;
display: inline-block;
}
.content-box .side-text {
width: 56%;
}
.content-box a {
color: #FF7954;
padding: 0;
}
.thesis .main-pic-box {
padding: 1rem 1rem 1.5rem 1.5rem;
}
/* Courses Section */
.courses {
display: flex;
justify-content: center;
flex-flow: column;
align-items: center;
}
.course-container {
width: 90%;
display: flex;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 2rem;
}
.course-box {
width: 30%;
height: auto;
margin: 0 0.5rem 1rem 0.5rem;
background-color: #ADBED3;
}
.courses h2, .thesis h2 {
text-align: center;
}
.course-box img {
width:100%;
}
.course-text {
padding: 1rem 0 0 1rem;
margin: 1.5rem auto;
}
/* Footer Section*/
footer {
background-color: white;
border-top: 1px solid #01161E;
display: flex;
justify-content: space-between;
position:relative; /* handle fixed menu bar */
top: 4rem;
width: 100%
}
footer h5 {
font-family: "Roboto", sans-serif;
display: inline-block;
padding: 1rem 1.5rem;
margin-bottom: 1.5rem;
}
footer nav {
align-self: auto;
padding-top: 1rem;
}
footer span {
padding-left: 1rem;
}
/* Tablet Settings for Smoother Transition */
@media only screen and (max-width:825px) {
.landing-box img, .main-pic-box {
width: 40%;
}
.landing-box .side-text, .stacked-content-box {
width: 45%;
}
.course-box {
width: 45%;
}
}
/* Mobile Settings */
@media only screen and (max-width:470px) {
/* Do Not Display */
footer nav, .desktop, .logo, .information .main-pic-box,
.thesis .stacked-content-box, .thesis p, .thesis h3, .course-box img,
.course-box p, #pc-pic {
display: none;
}
/* Mobile Header */
.mobile {
display: flex;
justify-content: space-around;
width: 100%;
}
.mobile img {
width: auto;
height: 90%;
}
/* Mobile Start Banner */
.start {
width: 100%;
align-self: center;
}
.landing-box img {
width: 90%;
padding: 2rem 1rem;
margin: auto;
}
.landing-box .side-text {
width: 100%;
padding: 0 1rem;
margin: auto;
}
/* Mobile Campus Section */
.stacked-content-box, .content-box .side-text{
width: 100%;
background-color: white;
}
.content-box {
display: flex;
flex-flow: column;
}
#mobile-pic {
display: block;
box-sizing: border-box;
padding: 1rem 1rem 1.5rem 1rem;
}
.content-box img {
width: 100%;
margin: auto;
background-color: white;
}
.content-box .side-text {
box-sizing: border-box;
padding: 1rem;
}
.content-box a {
font-size: 1rem;
}
/* Mobile Courses Section */
.courses {
border-top: 1px solid #8A97A8;
border-bottom: 1px solid #8A97A8;
}
.course-container {
flex-flow: column;
}
.course-box {
width: 100%;
height: auto;
padding: 0;
margin: 0 0 0.5rem 0;
}
.course-text {
padding: 1rem;
}
/* Mobile Thesis Section */
.thesis .main-pic-box {
width: 100%;
padding: 0 0 2rem 0;
}
video {
margin:auto;
}
/* Mobile Footer */
h5 {
margin: 1.5rem 0 0 0;
}
}