
The process of conceiving and constructing a presentation is often hard.
Sometimes we're stuck with Keynote or PowerPoint, and the templates are extremely limited and generic.
Today, we're going to learn how to create an awesome and animated presentation using HTML, CSS, and JavaScript.
If you're a beginner, don't worry! This tutorial will be easy enough to keep up with.
For this progect, we're going to use a framework called Reveal.js.
It provides robust functionality for creating interesting and customizable presentations.
- Go to the Reveal.js repository and clone the project
- Change directories into your newly cloned folder and run npm install to download the package dependencies. Then run npm start to run the project.
Built-In Themes
Reveal includes 11 themes. At this point, you will surely want to know how to change a theme
- Open index.html
- Change the CSS import to reflect the theme you want to use
The theme files are:
- beige.css
- black.css
- blood.css
- league.css
- moon.css
- night.css
- serif.css
- simple.css
- sky.css
- solarized.css
- white.css
Let's create a custom theme.
- Open css/theme/src inside your IDE. This holds all of the Sass files (.scss) for each theme. You can use a JavaScript task runner like Grunt (the files will be transpiled to CSS) or you can just create the CSS file inside css/theme.
- If you decide to use a JavaScript task runner, now you have to create a new .scss file. You can call the file custom.scss. You may have to stop your localhost and run npm run build to transpile your Sass code to CSS.
- Inside the index.html file, change the CSS theme import in the <head>tag to use the name of the newly created stylesheet.
- Now you can created variables for all of the different styles you want to use.
IMPORTANT: If you decide to use a JavaScript task runne add a .reveal class to the custom Sass file.
Mixins & Settings
Reveal.js also allows mixins and settings you can leverage in your custom theme.
To use them, just import the files:
@import "../template/mixins"; @import "../template/settings";
Playing with elements
The structure for adding new content is:
.reveal > .slides > section
The <section>
element represents one slide. Add as many sections as you need for your content.
How to make vertical slides
To create vertical slides, simply nest sections.
How to add Transitions
There are 6 different slide transitions to choose from:
- None
- Fade
- Slide
- Convex
- Concave
- Zoom
To use them, add a data-transition="{name}"
to the <section>
which contains your slide data.
How to add Fragments
Fragments are great for highlighting specific pieces of information on your slide. Here is an example.
To use fragments, add a class="fragment {type-of-fragment}"
to your element.
The types of fragments can be:
- grow
- shrink
- fade-out
- fade-up
- fade-in-then-out
- fade-in-then-semi-out
- highlight-current-blue
- highlight-red
- highlight-green
- highlight-blue
You can additionally add indices to your elements to indicate in which order they should be highlighted or displayed by using the data-fragment-index={index} attribute.
Enjoy!
Image by StartupStockPhotos from Pixabay
Janeth Kent
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.
Related Posts
Mastering array sorting in JavaScript: a guide to the sort() function
In this article, I will explain the usage and potential of the sort() function in JavaScript. What does the sort() function do? The sort() function allows you to sort the elements of…
Infinite scrolling with native JavaScript using the Fetch API
I have long wanted to talk about how infinite scroll functionality can be implemented in a list of items that might be on any Web page. Infinite scroll is a technique…
Sorting elements with SortableJS and storing them in localStorage
SortableJS is a JavaScript extension that you will be able to use in your developments to offer your users the possibility to drag and drop elements in order to change…
What is a JWT token and how does it work?
JWT tokens are a standard used to create application access tokens, enabling user authentication in web applications. Specifically, it follows the RFC 7519 standard. What is a JWT token A JWT token…
Why shouldn't we use black?
Nowadays it is becoming more and more common for web pages to have the option to set them in dark mode, or to base their aesthetics directly on black or…
Template Literals in JavaScript
Template literals, also known as template literals, appeared in JavaScript in its ES6 version, providing a new method of declaring strings using inverted quotes, offering several new and improved possibilities. About…
How to use the endsWith method in JavaScript
In this short tutorial, we are going to see what the endsWith method, introduced in JavaScript ES6, is and how it is used with strings in JavaScript. The endsWith method is…
Loading images by resolution with HTML5
Normally the way to load images in HTML is through the img element to which we pass as a parameter the URL of the image to load. But since HTML5…
What are javascript symbols and how can they help you?
Symbols are a new primitive value introduced by ES6. Their purpose is to provide us unique identifiers. In this article, we tell you how they work, in which way they…
Callbacks in JavaScript
Callback functions are the same old JavaScript functions. They have no special syntax, as they are simply functions that are passed as an argument to another function. The function that receives…
How to create PDF with JavaScript and jsPDF
Creating dynamic PDF files directly in the browser is possible thanks to the jsPDF JavaScript library. In the last part of this article we have prepared a practical tutorial where I…
How to make your own custom cursor for your website
When I started browsing different and original websites to learn from them, one of the first things that caught my attention was that some of them had their own cursors,…