0% found this document useful (0 votes)
3 views7 pages

Create a Stylish Preloader with JS

The document provides instructions for creating a pre-loader using HTML, CSS, and JavaScript. It includes step-by-step guidance on setting up the necessary files and code snippets for the pre-loader functionality. Additionally, it offers an example of a simple digital clock with corresponding HTML, JavaScript, and optional CSS code.

Uploaded by

raymondalougta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Create a Stylish Preloader with JS

The document provides instructions for creating a pre-loader using HTML, CSS, and JavaScript. It includes step-by-step guidance on setting up the necessary files and code snippets for the pre-loader functionality. Additionally, it offers an example of a simple digital clock with corresponding HTML, JavaScript, and optional CSS code.

Uploaded by

raymondalougta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

The code in the comments below will generate a pre-loader for you.

Technologies : Javascript, HTML and CSS.

How to test ?

1. Create a folder(You can call the folder anything you like. May be
« Preloader »)

2. Create a file called « [Link] » inside the folder you created above

3. Create another file for Javascript, call it « [Link] ».

4. Create the last file « [Link] »

5. Check the comments below for the respective code for those files you
just created.

6. Save every page changes and run the « [Link] »

Enjoy the beautiful Pre-loader.

Happy coding !

[Link] code :

< !DOCTYPE html>

<html lang= »en »>

<head>

<meta charset= »UTF-8 » />

<meta name= »viewport » content= »width=device-width, initial-


scale=1.0 » />

<title>Dark Mode Preloader</title>

<link rel= »stylesheet » href= »[Link] » />

</head>

<body>

< !—Preloader 

<div id= »preloader »>


<div class= »loader »></div>

</div>

< !—Main Content 

<div class= »content »>

<h1>Welcome to the Dark Side 🌑</h1>

<p>Your content will appear after the loader fades away.</p>

</div>

<script type= »module » src= »[Link] »></script>

</body>

</html>

[Link] code :

// Modern JavaScript (ES6+)

[Link](‘load’, () => {

Const preloader = [Link](‘preloader’) ;

Const content = [Link](‘.content’) ;

// Add fade-out class to preloader

[Link](‘fade-out’) ;

// Reveal content after fade duration

setTimeout(() => {

[Link](‘visible’) ;

[Link] = ‘auto’ ;
}, 700) ; // Must match –fade-duration

}) ;

[Link] code :

:root {

--background-color : #0d1117 ;

--loader-color : #58a6ff ;

--fade-duration : 0.7s ;

--font-family : ‘Segoe UI’, sans-serif ;

 {

Margin : 0 ;

Padding : 0 ;

Box-sizing : border-box ;

Body, html {

Height : 100% ;

Font-family : var(--font-family) ;

Background-color : var(--background-color) ;

Color : white ;

Overflow : hidden ;

#preloader {

Position : fixed ;
Top : 0 ;

Left : 0 ;

Width : 100% ;

Height : 100% ;

Background-color : var(--background-color) ;

Display : flex ;

Justify-content : center ;

Align-items : center ;

z-index : 9999 ;

transition : opacity var(--fade-duration) ease, visibility var(--fade-


duration) ;

/* Continuous loader animation */

.loader {

Width : 70px ;

Height : 70px ;

Border : 6px solid rgba(255, 255, 255, 0.1) ;

Border-top : 6px solid var(--loader-color) ;

Border-radius : 50% ;

Animation : spin 1.2s cubic-bezier(0.5, 0.1, 0.1, 1) infinite ;

@keyframes spin {

To {

Transform : rotate(360deg) ;

}
/* Fade out preloader */

#[Link]-out {

Opacity : 0 ;

Visibility : hidden ;

/* Page content styles */

.content {

Opacity : 0 ;

Padding : 60px 20px ;

Text-align : center ;

Transition : opacity 1s ease-in ;

.[Link] {

Opacity : 1 ;

Voici un exemple de code pour une horloge numérique simple :

**HTML**

```

< !DOCTYPE html>

<html>

<head>
<title>Horloge Numérique</title>

</head>

<body>

<h1 id= »horloge »></h1>

<script src= »[Link] »></script>

</body>

</html>

```

**JavaScript ([Link])**

```

Function afficherHeure() {

Var date = new Date() ;

Var heure = [Link]() ;

Var minute = [Link]() ;

Var seconde = [Link]() ;

Heure = (heure < 10) ? « 0 » + heure : heure ;

Minute = (minute < 10) ? « 0 » + minute : minute ;

Seconde = (seconde < 10) ? « 0 » + seconde : seconde ;

[Link](« horloge »).innerHTML = heure + « : » +


minute + « : » + seconde ;

setInterval(afficherHeure, 1000) ;

```

**CSS (facultatif)**

```

#horloge {

Font-size : 48px ;

Font-weight : bold ;

}
```

Qu’est-ce que vous voulez faire maintenant ?

- Ajouter la date

- Changer la police d’écriture

- Autre ?

You might also like