Discover the secret to achieving the perfect onload screen effect

Can someone please help me achieve the initial onload effect on my website? I am currently using Bootstrap 4 and JavaScript, but I am new to JavaScript. You can check out the template I'm referring to here.

Answer №1

Implement a method to place an element above all other content, then execute a script on document load to manipulate the element.

For example:

jQuery(document).ready(function(){
  jQuery('.overlay-load').addClass('away');
  jQuery('.overlay-aux-bg').addClass('away');
});
.overlay-load {
position: fixed;
z-index: 10;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: darkorange;
transition-duration: 500ms;
transition-delay: 2.5s;
}
.overlay-load.away {
transform: translateY(-100%);
}
.overlay-aux-bg {
position: absolute;
z-index: 10;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: #3c3c3c;
transition-duration: 500ms;
transition-delay: 1.5s;
}
.overlay-aux-bg.away {
transform: translateY(-100%);
}
.overlay-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
color: white;
font-size: 2em;
text-shadow: 0 1px 1px #bbb,
0 2px 0 #999, 
0 3px 0 #888, 
0 4px 0 #777, 
0 5px 0 #666, 
0 6px 0 #555, 
0 7px 0 #444, 
0 8px 0 #333, 
0 9px 7px #302314;
}
.page-content {
position: relative;
width: 100%;
height: 100%;
min-height: 100vh;
}
.content-sample-format {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="overlay-load">
<div class="overlay-aux-bg">
<div class="overlay-text">
Load Screen Text
</div>
</div>
</div>
<div class="page-content">
<div class="content-sample-format">
<h1>Page title</h1>
<p>Page content to show the page in action haha </p>
</div>
</div>

This involves a small amount of JavaScript and a combination of CSS styles. It's recommended to use JavaScript for adding classes to elements. You can also introduce a timeout function for delayed class addition, but utilizing transition delays serves the same purpose without additional complexity. By adding classes to elements in this manner, it improves performance efficiency.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

PHP script automatically resets select option on page load

Consider the following scenario: <form name="limit"> <select name="limiter" onChange="limit(this.value)"> <option selected="selected">&nbsp;</option> <option value="5">5</option> <opti ...

Unexpected issue encountered when working with JSON in Node.js

I've searched through countless solutions on stackoverflow, but none of them seem to work for me. It's really frustrating not understanding what's going wrong. Below is the code I'm having trouble with: var data = ""; req.on('dat ...

Django will not be replacing the outdated image

My Django App is designed to display images on the browser based on user selections in the UI. Whenever there is a change in the UI, a JavaScript function is triggered that makes a call to a Django view. Each time I modify the UI in the browser, a new ima ...

What methods can a Java application use to distinguish one browser from another?

Is there a way to determine if the browser being used is Firefox or Chrome? I am looking to create an application that will only run on a specific browser registered by a user. To achieve this, my application needs to be able to identify which browser the ...

External IPs cannot access Node.js

I am facing an issue with my Amazon EC2 Server where I have set up a node js server. It is not accessible from the outside using the public DNS, but it can be accessed from the same instance (localhost). Any assistance in resolving this problem would be gr ...

Modifying CSS content attribute in real-time

A colleague of mine has rented a webshop from a company. They have the option to select different templates and are also able to customize the CSS and add Javascript snippets. They reached out to me for help with making some modifications, but there's ...

"Converting to Typescript resulted in the absence of a default export in the module

I converted the JavaScript code to TypeScript and encountered an issue: The module has no default export I tried importing using curly braces and exporting with module.exports, but neither solution worked. contactController.ts const contacts: String[ ...

Issue with NPM Scripts Post Hook Triggering

Currently, I am exploring the use of npm scripts to gradually phase out my dependency on Gulp. To begin, I have created a single custom script called watch. This script will eventually execute all other scripts prefixed with the name watch, such as watch:s ...

Troubleshooting a non-functional Express server demonstration

On my remote server, I currently have node v7.4.0 installed. Recently, I updated to the latest version of express (4.14.0) and set up a file named index.js in my public_html directory. This index.js file is an exact copy of the official online test code sn ...

Guidelines on declining a pledge in NativeScript with Angular 2

I have encountered an issue with my code in Angular 2. It works fine in that framework, but when I tried using it in a Nativescript project, it failed to work properly. The problem arises when I attempt to reject a promise like this: login(credentials:Cr ...

Using jQuery to Send Data Back to Parent Popup Window

Is there a way to achieve the following functionality with jQuery: create a popup window that sends a value back to the main window when a link in the popup is clicked, then closes the popup and automatically submits a form in the main window based on the ...

Accessing WCF REST endpoint using Ajax and transmitting data in JSON format

I have developed a Rest service in WCF (demo), which provides me with the following output: {"GetEmployeeJSONResult":{"Id":101,"Name":"Sumanth","Salary":5000}} Now, I have created an ASP.NET website where I am utilizing AJAX JSON to call this rest service ...

In Google Chrome, Angular does not display a tool tip when a button is disabled

I've utilized angular along with ng-bootstrap for a project I'm working on. The issue arises when using ngbTooltip to display a tooltip on a button. <button class="btn btn-success" (click)="onSubmit()" [ngbTooltip]="tipContent" ...

Encountering Issues with Npm Install

I encountered some issues while running npm install on a cloned project. Despite executing npm install in the correct folder, I continued to receive multiple errors on my terminal. The error messages are displayed below this message. Any assistance would ...

If I click on a different VueJS menu, make sure to close the current menu

When using a component menu, each item is displayed independently. However, I would like the open items to close automatically when I click on another item with the menu. I employ a toggle functionality on click to control the opening and closing of the c ...

tips for sending a chosen item to the Vujes API

How can I send the selected item from a dropdown to an API in Vue.js? <select :v-model="selectedRole" class="custSelect"> <option v-for="option in options" v-bind:value="option.value"> {{option.role}} </option> ...

Struggling to delete elements from observable array within Knockoutjs framework

I am attempting to use knockoutjs to remove a user from an observable array called users. It seems like my viewModel may not be working correctly because it is within a document.ready function. Here is some context about the code below: My application fet ...

Catalog of items in Mustache

I am currently working on generating HTML content using the mustache template engine. However, I have encountered an issue when trying to render a list of objects. Below is an example of my object: var Prod={ "Object1": { "name": "name1", "cat ...

Discover the position of a dynamically added element

Is there a way to identify the specific dynamically added checkbox that was clicked, whether by index or name? I came across a similar question with a solution in this JSFiddle: JSFiddle Instead of just displaying "clicked", I would like it to show someth ...

A guide on incorporating React components from a locally installed npm package

Recently, I've been working on developing an npm package that contains a collection of React components that are essential for all my projects. Let me walk you through the folder structure and contents: / dist/ bundle.js src/ MyComponent.jsx ...