This responsive web page contains a showcase of hero blocks with various fonts and alignments, and with a range of background colours, gradients and images. You can display a finished version of this project on GitHub by clicking the image below.
At the end of this Tutorial you will be able to:
Your first step is to download the files you need for this project.


This will create a sub-folder named hero inside your portfolio folder.
The folders, sub-folders and files for this 'Hero' project will be as shown below.
Now you can begin to work with the files you have downloaded.
You can close any other files you may have open in your text editor.
As you work with the HTML and CSS files, you will want to be able to display in your web browser the results of the changes you will be making.
If not, right-click the index.html file and, from the pop-up menu displayed, choose Open with and then select either Firefox Developer Edition or Google Chrome to open the file.
In your web browser, the index.html file should look as shown below.
When you look at the source code of the index.html you can see six 'boxes' of content:
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.
All six hero blocks in this project have the following common features:

You achieve this by making each hero block a flexbox (display: flex), and then giving the block a flex-direction of column and a justify-content value of center. This vertical justification feature is available only to divs that are set as flexbox divs.

A few points to note about the text content of the six hero blocks:

You can see the Google Fonts within the <head>...</head> section of the HTML file.


In the remainder of this project, you will build each of the six hero blocks. Your first step will be to create the CSS declarations for the first of the six hero blocks. These you will then copy-and-paste to use as a basis for styling the other ten hero blocks.
Follow these steps to create the styles for the <div>s named 'hero-block-1.'
/*== HERO BLOCK 1 ==*/
.hero-block-1 {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #0065f2;
}
.hero-block-1 h1, .hero-block-1 h2 {
font-family: 'Open Sans', sans-serif;
color: #fff;
font-weight: bold;
text-align: center;
margin-left: auto;
margin-right: auto;
line-height: 1.4
}
.hero-block-1 h1 {
font-size: calc(36px + (72 - 36) * ((100vw - 320px)/(1600 - 320)));
}
.hero-block-1 h2 {
font-size: calc(20px + (32 - 20) * ((100vw - 320px)/(1600 - 320)));
}
/* Mobiles - height and bottom margin, text width */
@media all and (max-width:767px) {
.hero-block-1 { height: 360px; margin-bottom: 40px }
.hero-block-1 h1, .hero-block-1 h2 { width: 80% }
.hero-block-1 h1 { margin-bottom: 10% }
}
/* Desktop - height and bottom margin, text width */
@media all and (min-width:768px) {
.hero-block-1 { height: 480px; margin-bottom: 70px }
.hero-block-1 h1, .hero-block-1 h2 { width: 60% }
.hero-block-1 h1 { margin-bottom: 4% }
}

Follow these steps to create the CSS styles for the <div> in your index.html file named 'hero-block-2.'
/* === HERO BLOCK 2 === */
.hero-block-2 {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #78d8da;
}
.hero-block-2 h1, .hero-block-2 h2 {
font-family: 'Montserrat', sans-serif;
color: #000;
font-weight: bold;
text-align: left;
margin-left: auto;
margin-right: auto;
line-height: 1.5
}
.hero-block-2 h1 {
font-size: calc(32px + (84 - 32) * ((100vw - 320px)/(1600 - 320)));
}
.hero-block-2 h2 {
font-size: calc(18px + (32 - 18) * ((100vw - 320px)/(1600 - 320)));
font-weight: normal
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-2 { height: 360px; margin-bottom: 40px }
.hero-block-2 h1, .hero-block-2 h2 { width: 80% }
.hero-block-2 h1 { margin-bottom: 10% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-2 { height: 480px; margin-bottom: 80px }
.hero-block-2 h1, .hero-block-2 h2 { width: 60% }
.hero-block-2 h1 { margin-bottom: 4% }
}
Here is a summary of the changes:

Follow these steps to create the CSS styles for the <div> in your index.html file named 'hero-block-3.'
/* === HERO BLOCK 3 === */
.hero-block-3 {
display: flex;
flex-direction: column;
justify-content: center;
background-image: linear-gradient(#512d6d,#c42f9e);
}
.hero-block-3 h1, .hero-block-3 h2 {
font-family: 'Open Sans', sans-serif;
color: #fff;
font-weight: bold;
text-align: left;
margin-left: auto;
margin-right: auto;
line-height: 1.4
}
.hero-block-3 h1 {
font-size: calc(32px + (72 - 32) * ((100vw - 320px)/(1600 - 320)));
}
.hero-block-3 h2 {
font-size: calc(18px + (32 - 18) * ((100vw - 320px)/(1600 - 320)));
font-weight: normal
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-3 { height: 360px; margin-bottom: 40px }
.hero-block-3 h1, .hero-block-3 h2 { width: 70% }
.hero-block-3 h1 { margin-bottom: 5% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-3 { height: 480px; margin-bottom: 80px }
.hero-block-3 h1, .hero-block-3 h2 { width: 60% }
.hero-block-3 h1 { margin-bottom: 1% }
}
Here is a summary of the changes:

Follow these steps to create the CSS styles for the <div> in your index.html file named 'hero-block-4.'
/* === HERO BLOCK 4 === */
.hero-block-4 {
display: flex;
flex-direction: column;
justify-content: center;
background-image: url('../img/hotel-dark.jpg');
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
}
.hero-block-4 h1, .hero-block-4 h2 {
font-family: 'Open Sans', sans-serif;
color: #fff;
font-weight: bold;
text-align: center;
margin-left: auto;
margin-right: auto;
line-height: 1.4;
text-shadow: 2px 2px #222
}
.hero-block-4 h1 {
font-size: calc(60px + (112 - 60) * ((100vw - 320px)/(1600 - 320)));
}
.hero-block-4 h2 {
font-size: calc(24px + (54 - 24) * ((100vw - 320px)/(1600 - 320)));
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-4 { height: 360px; margin-bottom: 40px }
.hero-block-4 h1, .hero-block-4 h2 { width: 70% }
.hero-block-4 h1 { margin-bottom: 5% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-4 { height: 480px; margin-bottom: 80px }
.hero-block-4 h1, .hero-block-4 h2 { width: 60% }
.hero-block-4 h1 { margin-bottom: 1% }
}
For all screen sizes, you have made the following changes to the background of the hero block:

Follow these steps to create the CSS styles for the <div> in your index.html file named 'hero-block-5.'
/* === HERO BLOCK 5 === */
.hero-block-5 {
display: flex;
flex-direction: column;
justify-content: center;
background-image: linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.3)),url('../img/bike-tours.jpg');
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
}
.hero-block-5 h1, .hero-block-5 h2 {
font-family: 'Montserrat', sans-serif;
color: #fff;
font-weight: bold;
text-align: center;
margin-left: auto;
margin-right: auto;
line-height: 1.4;
text-shadow: 2px 2px #222
}
.hero-block-5 h1 {
font-size: calc(60px + (112 - 60) * ((100vw - 320px)/(1600 - 320)));
line-height: 1.2
}
.hero-block-5 h2 {
font-size: calc(24px + (54 - 24) * ((100vw - 320px)/(1600 - 320)));
font-family: 'Roboto Condensed', sans-serif;
text-transform: uppercase;
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-5 { height: 360px; margin-bottom: 40px }
.hero-block-5 h1, .hero-block-5 h2 { width: 80% }
.hero-block-5 h1 { line-height: 1.2; margin-bottom: 10% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-5 { height: 480px; margin-bottom: 80px }
.hero-block-5 h1, .hero-block-5 h2 { width: 80% }
.hero-block-5 h1 { margin-bottom: 5% }
}
For all screen sizes, make these two changes to the background image:

Follow these steps to create the CSS styles for the <div> in your index.html file named 'hero-block-6.'
/* === HERO BLOCK 6 === */
.hero-block-6 {
display: flex;
flex-direction: column;
justify-content: center;
background-image: linear-gradient(rgba(0,0,255,0.5),rgba(0,0,255,0.5)),url('../img/meeting.jpg');
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
}
.hero-block-6 h1, .hero-block-6 h2 {
font-family: 'Roboto Condensed', sans-serif;
color: #fff;
font-weight: bold;
text-align: center;
margin-left: auto;
margin-right: auto;
line-height: 1.4;
text-shadow: 2px 2px #222;
text-transform: uppercase;
}
.hero-block-6 h1 {
font-size: calc(34px + (76 - 34) * ((100vw - 320px)/(1600 - 320)));
}
.hero-block-6 h2 {
font-size: calc(22px + (40 - 22) * ((100vw - 320px)/(1600 - 320)));
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-6 { height: 360px; margin-bottom: 40px }
.hero-block-6 h1, .hero-block-6 h2 { width: 80% }
.hero-block-6 h1 { line-height: 1.2; margin-bottom: 10% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-6 { height: 480px; margin-bottom: 80px }
.hero-block-6 h1, .hero-block-6 h2 { width: 80% }
.hero-block-6 h1 { margin-bottom: 5% }
}
/* Mobiles */
@media all and (max-width:767px) {
.hero-block-6 { height: 360px; margin-bottom: 40px }
.hero-block-6 h1, .hero-block-6 h2 { width: 70% }
.hero-block-6 h1 { margin-bottom: 10% }
}
/* Desktop */
@media all and (min-width:768px) {
.hero-block-6 { height: 480px; margin-bottom: 80px }
.hero-block-6 h1, .hero-block-6 h2 { width: 60% }
.hero-block-6 h1 { margin-bottom: 2% }
}

In the final step below, you will animate the text headlines for the 'hero-1' block so that they slide in from the top of the web page. To generate the CSS code required for the animation effect, you will use the Animista website created by Ana Travas.




.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;
}
/* === HERO BLOCK 2 === */

/* ----------------------------------------------
* 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;
}
}
/* === HERO BLOCK 2 === */
<div class="hero-block-1">
<>Hello, IBATCrypto</h1>
<>Announcing the smart and fast way to accept payments in crypto currencies.</h2>
</div>
.slide-in-top {
-webkit-animation: slide-in-top 1s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-in-top 1s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
Near the top of your HTML file, just before the closing </head> tag, you can see a sample Google Analytics Tracking Code.
Each Google Tracking Code has a unique ID in its first and last line. Replace the sample Google Tracking ID with your own Google Tracking ID. The instructions for viewing your website’s unique Google Tracking ID are here.
When finished, save the index.html file.
You need to edit the ‘pop-up‘ privacy code and message in your web page.
Near the end of the lines of the JavaScript code, you can see the web address of the privacy page. Change the ibat-web-dev.github.io username to your username on GitHub.
You will create the actual privacy.html web page in a later project.You can find the instructions for generating the JavaScript code here.
And here is a sample template file with the privacy message and code.
The web page looks 'empty'. Right-click anywhere on the page and choose View page source (Chrome or Mozilla Firefox).
To check your HTML is correct, use the official W3C Markup Validation Service. Follow these steps.

To check your CSS is correct, use the official W3C CSS Validation Service. Follow these steps.


The final step is to upload your project to GitHub.
All the files for this project are in a sub-folder named hero of your websites/portfolio folder.
So you will need to upload this hero sub-folder, which contains both files and other sub-folders, to your account on GitHub.








Your web page is now published on GitHub at a web address similar to the following, where username is the username you have chosen for your GitHub account:
https://username.github.io/portfolio/hero/index.html
or, simply:
https://username.github.io/portfolio/hero
It may take a few minutes for your uploaded files to appear on GitHub.
Return to Contents.