Adding a New Section
Last updated
Last updated
Let's say we want to add a new section. First, we need to update the navigation menu by adding a new <li></li> element:
Always remember to add the classes nav__tab, nav__tab--[section number] as well as the data attribute ( data-tab=[section number] ) with its respective section number.
Then we can add the section content at the bottom of the code, after the section:
Remember to add the classes section__tab and section__tab--[section number] with its respective section number since it is necessary for the section to be displayed.
To make the index and title appear you can use the following structure:
Highlight Effect to a Title
To highlight a word in the title (or any other word in the template), follow these steps:
Wrap the word you want to highlight in a <span>
tag.
Add the class marked
to the <span>
tag.
For example, in your HTML, it would look like this:
How to Apply Animations to Elements:
In the HTML, simply add the data-animation
attribute to the element you want to animate, and assign the animation name.
For example:
The available animations in your template are defined in the CSS using @keyframes
to create transformation and opacity transitions, as shown below:
Each animation has a set duration and transition type (e.g., ease
, forwards
) to control the timing and end state of the animation.
Ensure that the HTML elements you want to animate have the appropriate data-animation
attribute.
The animations are controlled by the app.js
file located in the js
folder. This script ensures that the correct animation is applied when the data-animation
attribute is detected in the HTML.
How to Apply Animations Using the Intersection Observer:
Certain elements in the template are animated when they come into view, thanks to the Intersection Observer. These animations are triggered by adding either the animated-up
or animated-scale
class to an element.
HTML Structure
To animate an element, simply add the animated-up
or animated-scale
class to it. For example:
CSS Animations
The animated-up
and animated-scale
classes are defined in the CSS to create the animations. When the element enters the viewport, these classes are animated with transitions for opacity and transform:
JavaScript (Intersection Observer)
The Intersection Observer in your app.js
file handles the detection when an element with the animated
or animated-scale
class comes into view. When the element is visible, the observer adds the animated-item
or animated-scale-item
classes to trigger the animation:
This script ensures that elements with the animated
or animated-scale
class are animated when they are scrolled into view. The setTimeout
with the index * 100
adds a slight delay to each element to make the animations appear sequentially.