Keep track of all the useful lessons, tips, and tricks we come across during FAC-15
.
Each tip should indlude a short description and How To. We'll also do our best to include the live version and repo of the project, and a link for further reading.
This file is a work in progress, aimed to allow everyone to contribute. Please feel free to edit it to make things clearer.
-
We found a quick and simple way to add smooth scrolling to the entire html page with no JS code. To apply it to your project, add this next block of code to your
css
file:html { scroll-behavior: smooth; }
-
⚠️ This does not support all browsers/ all browser versions: It currently doesn't work on Safari & Explorer. Also doesn't work on Chrome versions older than61.0
nor on Firefox versions older than36.0
. -
📖 Resource: w3schools
-
We used Font Awesome to add icons and logo to our portfolio. The way to do this is to first Include the font awesome library in your
index.html
>head
tag:<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
Then, use a
span
tag to add icons, like so:<span class="fas fa-pencil-alt fa-3x colorcss" ></span>
The code above adds a pencil shaped icon to the page. The
fa-3x
sets the icon size. We chose to make it three times bigger than its original size. We also added our own project class namecolorcss
, that adds a specific color to the icon. -
📖 Resource: Font Awesome: Getting Started
In the html, write "" for the email box. Add "<input type=text">" for the names, and "" for the submit button. More on this here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
We nicked code from an article for this, and altered it to fit our purpose. Will see if Mike can get the link...
We used regex rules, and added an eventListener on the submit button, resulting in a relevant alert message if certain criteria wasn't met (i.e no name inputted, or an invalid email address).
I (Charlie) personally think that other groups' use of the type attribute in the HTML input tag is an easier and nicer way to achieve this! Likewise for the pattern attribute instead of writing out regex rules in the JS file.
Useful resource for testing regex - https://regex101.com/ . Thanks Hannah
To create a html skeleton on vs code, type ! and press the tab key.