At the end of this Tutorial you will be able to:
You can view a finished version of the sample web page you will update in this Tutorial by clicking the link below. The finished sample will open in a new tab of your web browser.
So-called hero blocks (sometimes known as jumbotrons) are large and typically rectangular areas at the very top of a web page.
They are the first item seen by users, and are intended to capture their attention and engage their interest in the web page.
In this exercise, you will work with the following two files, a web page and a stylesheet:
You have now saved the two files you need for this exercise.
In this section, you will update the styles of the hero-1 block within your sample files.
Your first task is to update the background colour of the hero-1 container.
hero-1 { ... background-image: linear-gradient(90deg, #ff00cc, #333399); }Note: The three dots ... simply refers to all the other styles for the CSS selector.
Your second task is to add a Google Font for all the text within the hero-1 container. The Google Font named Open Sans has already been added to the web page and is available to your CSS file.
.hero-1 h1 { ... font-family: 'Open Sans', sans-serif; }
.hero-1 h2 { ... font-family: 'Open Sans', sans-serif; }
.hero-1 .container-btn a.btn-primary, .hero-1 .container-btn a.btn-secondary { ... font-family: 'Open Sans', sans-serif; }
Next, you will update the styles that control the passive and interactive states of the two hyperlinks styled as buttons within the btn-container of the hero-1 block container.
.hero-1 a.btn-primary:link, .hero-1 a.btn-primary:visited { color: #fff; border: solid 2px red; background-color: red; transition: all 0.2s linear; }
.hero-1 a.btn-primary:focus, .hero-1 a.btn-primary:hover, .hero-1 a.btn-primary:active { background-color: green; border: solid 2px green; }
.hero-1 a.btn-secondary:link, .hero-1 a.btn-secondary:visited { color: #fff; border: solid 2px #fff; transition: all 0.2s linear; }
.hero-1 a.btn-secondary:focus, .hero-1 a.btn-secondary:hover, .hero-1 a.btn-secondary:active { color: lightblue; border: solid 2px lightblue; }
/* === GLOBAL BUTTON STYLES === */ /* Button shapes */ a.btn-soft { border-radius: 5px } a.btn-rounded { border-radius: 40px }
In the final update to the hero-1 block, you will add two icons from Font Awesome. The link to the Font Awesome stylesheet is included in the hero-single.html web page, and is so available to your CSS file.
/* Icon spacing inside buttons */ a.btn-primary i, a.btn-secondary i { margin-right: 12px }
In this section, you will update the styles of the hero-2 block within your sample files.
This second hero block has a similar structure to hero-1 block. The only difference is that both buttons have the same class of btn-primary.
Your first task is to update the background colour of the hero-2 container.
hero-2 { ... background-color: #1f364d; }
Your next task is to add Google Fonts for the text within the hero-2 container. The Google Fonts named Libre Baskerville and Open Sans have already been added to the web page and are available to your CSS file.
.hero-2 h1 { ... font-family: 'Libre Baskerville', sans-serif; }
.hero-2 h2 { ... font-family: 'Open Sans', sans-serif; }
.hero-2 .container-btn a.btn-primary { ... font-family: 'Open Sans', sans-serif; }
Next, you will update the styles of the two buttons within the hero-2 block. Both have a class of btn-primary.
.hero-2 a.btn-primary:link, .hero-2 a.btn-primary:visited { color: #1f364d; border: solid 2px #11ece5; background-color: #11ece5; transition: all 0.2s linear; }
.hero-2 a.btn-primary:focus, .hero-2 a.btn-primary:hover, .hero-2 a.btn-primary:active { background-color: hotpink; border: solid 2px hotpink; }
In the final update to the hero-2 block, you will add two icons from Font Awesome.
In this section, you will update the styles of the hero-3 block within your sample files.
This hero block has only one button rather than two. The single button has a class of btn-primary.
Your first task is to update the background colour of the hero-3 container.
hero-3 { ... background-color: #fabbb6; }
Your next task is to add Google Fonts for the text within the hero-3 container. The Google Fonts named Fjalla One and Open Sans have already been added to the web page and are available to your CSS file.
.hero-3 h1 { ... font-family: 'Fjalla One', sans-serif; }
.hero-3 h2 { ... font-family: 'Open Sans', sans-serif; }
.hero-3 .container-btn a.btn-primary { ... font-family: 'Open Sans', sans-serif; }
Next, you will update the styles of the button within the hero-3 block. It has a class of btn-primary.
.hero-3 .container-btn a.btn-primary { padding: 0 0 6px 0; }
.hero-3 a.btn-primary:link, .hero-3 a.btn-primary:visited { color: #000; border-bottom: solid 2px #000; transition: all 0.2s linear; }
.hero-3 a.btn-primary:focus, .hero-3 a.btn-primary:hover, .hero-3 a.btn-primary:active { color: red; border-bottom: solid 2px red; }
In the final update to the hero-3 block, you will add two icons from Font Awesome.
In this section, you will update the styles of the hero-4 block within your sample files.
This hero block has two buttons, each with a class of btn-primary.
Unlike previous hero blocks, the content of this block is left-aligned rather than centre-aligned.
Your first task is to update the background colour of the hero-4 container.
hero-4 { ... background-color: #3c1c78; }
Your next task is to add Google Fonts for the text within the hero-4 container. The Google Fonts named Roboto Slab and Roboto have already been added to the web page and are available to your CSS file.
.hero-4 h1 { ... font-family: 'Roboto Slab', sans-serif; }
.hero-4 h2 { ... font-family: 'Roboto', sans-serif; }
.hero-4 .container-btn a.btn-primary { ... font-family: 'Roboto', sans-serif; }
Next, you will update the styles of the two buttons within the hero-2 block. Both have a class of btn-primary.
.hero-4 a.btn-primary:link, .hero-4 a.btn-primary:visited { color: #fff; border: solid 2px red; background-color: red; transition: all 0.2s linear; }
.hero-4 a.btn-primary:focus, .hero-4 a.btn-primary:hover, .hero-4 a.btn-primary:active { background-color: green; border: solid 2px green; }
/* Button alignment within their containers */ .hero-4 .container-btn .item-col-2:first-child { text-align: left }
In the final update to the hero-4 block, you will add two icons from Font Awesome.
In this section, you will update the styles of the hero-5 block within your sample files.
This hero block has only a main heading but no sub-heading, and is left-aligned. It has one button, with a class of btn-primary.
Your first task is to update the background colour of the hero-5 container.
hero-5 { ... background-color: #fbf5eb; }
Your next task is to add Google Fonts for the text within the hero-5 container. The Google Fonts named Roboto Slab and Roboto have already been added to the web page and are available to your CSS file.
.hero-5 h1 { ... font-family: 'Libre Baskerville', sans-serif; }
.hero-5 .container-btn a.btn-primary { ... font-family: 'Open Sans', sans-serif; }
Next, you will update the styles of the two buttons within the hero-5 block. Both have a class of btn-primary.
.hero-5 .container-btn a.btn-primary { ... padding: 0 0 12px 0; }
.hero-5 a.btn-primary:link, .hero-5 a.btn-primary:visited { color: #000; border-bottom: dashed 2px #000; transition: all 0.2s linear; }
.hero-5 a.btn-primary:focus, .hero-5 a.btn-primary:hover, .hero-5 a.btn-primary:active { color: #000; border-bottom: dashed 2px red; }
In this next update to the hero-5 block, you will add two icons from Font Awesome.
In the final update to the hero-5 block, you will add two <span> tags with colour classes.
/* === GLOBAL TEXT COLOUR STYLES === */ .text-red { color: red } .text-darkgray { color: #888 }Save your stylesheet.
In the final step below, you will animate the text headlines for the hero-1 and hero-2 blocks so that they slide in from the top (hero-1) and from the left (hero-2) of the web page.
To generate the CSS code required for the animation effect, you will use the Animista website created by Ana Travas.
You will create the following two new classes in your hero-single.css stylesheet:
You can then apply these classes to elements in your linked hero-single.html web page.
Follow these steps to create the slide-in-top class in your hero-single.css stylesheet.
.slide-in-top { -webkit-animation: slide-in-top 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; animation: slide-in-top 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; }
/* ---------------------------------------------- * Generated by Animista on 2020-4-8 10:45:15 * Licensed under FreeBSD License. * See http://animista.net/license for more info. * w: http://animista.net, t: @cssanimista * ---------------------------------------------- */ /** * ---------------------------------------- * animation slide-in-top * ---------------------------------------- */ @-webkit-keyframes slide-in-top { 0% { -webkit-transform: translateY(-1000px); transform: translateY(-1000px); opacity: 0; } 100% { -webkit-transform: translateY(0); transform: translateY(0); opacity: 1; } } @keyframes slide-in-top { 0% { -webkit-transform: translateY(-1000px); transform: translateY(-1000px); opacity: 0; } 100% { -webkit-transform: translateY(0); transform: translateY(0); opacity: 1; } }You have now finished creating the slide-in-top class.
.slide-in-top { -webkit-animation: slide-in-top 1s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; animation: slide-in-top 1a cubic-bezier(0.250, 0.460, 0.450, 0.940) both; }
Follow these steps to create the slide-in-left class in your hero-single.css stylesheet.
.slide-in-left { -webkit-animation: slide-in-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; animation: slide-in-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; }
/* ---------------------------------------------- * Generated by Animista on 2020-4-8 10:45:15 * Licensed under FreeBSD License. * See http://animista.net/license for more info. * w: http://animista.net, t: @cssanimista * ---------------------------------------------- */ /** * ---------------------------------------- * animation slide-in-left * ---------------------------------------- */ @-webkit-keyframes slide-in-left { 0% { -webkit-transform: translateX(-1000px); transform: translateX(-1000px); opacity: 0; } 100% { -webkit-transform: translateX(0); transform: translateX(0); opacity: 1; } } @-webkit-keyframes slide-in-left { 0% { -webkit-transform: translateX(-1000px); transform: translateX(-1000px); opacity: 0; } 100% { -webkit-transform: translateX(0); transform: translateX(0); opacity: 1; } }
You have now finished creating the slide-in-left class.
You will now apply the two new animated text classes in your stylesheet to your web page.
That’s it. You have now successfully updated the sample file of hero blocks.
Click hero-single.html to view a finished sample of this web page in a new tab of your web browser.
Upload the following web page and stylesheet to your account on GitHub:
hero-single.html
hero-single.css
Your web page will be published at web addresses similar to the following:
https://username.github.io/hero-single.html
It may take a few minutes for your uploaded files to appear on GitHub.
Return to Contents.