Conceal the div until the animation with a delay of `1s` has finished, then reveal it afterwards

I have incorporated a CSS file to introduce animations on the website I am currently developing. You can find it here:

The premise of this CSS file is straightforward - by adding specific class names to div elements, you can animate them as you scroll up or down the page.

I am looking to make a modification that will introduce a slight delay between each animation. This way, when scrolling past multiple animations in sequence, they will appear one after the other instead of all at once.

My plan involves creating a new class name, such as delay-1, which would apply animate-delay: 1s to the element.

For reference, you can view an example of the desired effect here. Scroll down and observe how "Our Progress" showcases each animation with a delay:

Can this be achieved using CSS3 alone? Any guidance or assistance on this matter would be greatly appreciated.

Answer №1

Indeed, utilizing CSS3 transition can achieve the desired effect. I have a demo page that has been set up for quite some time now, which you can take a look at.

In the demonstration, the first item applies a 2-second delay while the second item has no delay at all. Best of luck!

#demo:hover {
width: 300px;
transition-delay: 2s
}

#demo1:hover {
width: 300px;
transition-delay: 0s
}

http://jsfiddle.net/zFbkL/

Answer №2

Here is a possible way to define the class:

.delay-1 {
    animation-delay: 1s !important;
    -webkit-animation-delay: 1s !important;
}

I'm not sure if it will be effective, but it's worth experimenting with. Yes, it did work for me and achieved the desired result.

Answer №3

If you want to target different sections with transitions as you scroll using JavaScript, you can achieve this by applying classes and utilizing the nth-child() selector.

Let's consider a scenario where there are 4 steps:

.steps .step:nth-child(1) { transition-delay: 1s; }
.steps .step:nth-child(2) { transition-delay: 2s; }
.steps .step:nth-child(3) { transition-delay: 3s; }
.steps .step:nth-child(4) { transition-delay: 4s; }

However, if your section has an unknown number of steps, it might be more efficient to dynamically set these delays using scripting.

$('.steps .step').each(function(i){
  $(this).css('animation-delay', i + 's');
});

To trigger the animations, simply add a class to .steps.

.steps .step { transition: all 1s; opacity: 0; width: 0;}
.steps.in-view .step { opacity: 1; width: auto; }

Hopefully, this helps you accomplish your desired effect.

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

SlickGrid checkbox formatter/editor experiencing issues with data consistency

Exploring the functionalities of SlickGrid'seditors/formatters, I delved into how these features could potentially alter the data object utilized for constructing the grid (as modifications within the table are usually reflected in the original data o ...

What is the best way to automatically have the first bar in a column highchart be selected when the page loads?

My highchart consists of a simple column. When I click on any bar in the chart, it gets selected. However, I also want the 1st bar to be selected by default. var chart = $('#container').highcharts(); Upon page load, I have obtained this object. ...

Retrieve a string value in Next.JS without using quotation marks

Using .send rather than .json solved the problem, thank you I have an API in next.js and I need a response without Quote Marks. Currently, the response in the browser includes "value", but I only want value. This is my current endpoint: export ...

Error: The property 'updateOne' cannot be read because it is undefined

I have been struggling to update an array in my MongoDB database, despite following the steps outlined in the official documentation. I can't seem to make it work. Can anyone provide assistance? I went through the official documentation, but unfortun ...

An issue occurred while running the "gulp test" command due to a problem with the 'gulp-tslint-log'

Having issues running gulp on a JHipster generated project. I've already installed all node_modules using npm install and here are my package.json and gulpfile.js: { "name": "myapp", "version": "0.0.0", "description": "Description for myapp", ...

The function of hasClass within an if statement appears to be malfunctioning

I'm struggling to figure out why my .hasClass function is not functioning correctly. I've implemented the Quick Search jQuery plugin, and below is the code I am using: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.mi ...

Transforming the hide/show functionality from JQuery to Vue

I created some hide/show panels using jQuery that I want to implement in Vue. However, when I try to integrate the jQuery functions into Vue, the functionality doesn't seem to work properly. The panels are not hiding/showing as expected. Does anyone ...

Executing PHP scripts using Ajax

Check out the code snippet below: <?php //echo $this->Html->css(array('bootstrap', 'mark', 'style')); echo $this->Html->script(array('timer','swfobject','bootstrap.min.js')); // ...

What is the best approach for handling @RequestParam in a JSP file?

Hello there! I have a query regarding the usage of @RequestParam in @RestController. My question is about extracting @RequestParam from the client side. Below is an example of server code using @RestController: @ResponseBody @RequestMapping(method = Reque ...

CSS shimmer effect does not smoothly transition between borders

Currently, I'm diving into a tutorial on YouTube that teaches how to craft a CSS Glowing Border Animation After putting in the effort to replicate the animation, I noticed a glitch that's been bothering me. It seems like there's an abrupt s ...

Why is TypeScript unable to recognize package exports? (using CommonJS as the module system and Node as the module resolution)

I have an NPM package that is built for ESM and CJS formats. The package has a dist folder in the root directory, which contains: dist/esm - modules with ESM dist/cjs - modules with CJS dist/types - typings for all modules In the package.json file, there ...

Unable to adjust the size of a DIV with a button click in Vue3

I am having trouble resizing a DIV block in Vue3. Whenever I click the button, I receive an error message saying "Cannot read properties of undefined (reading 'style')". I know there is an issue with the JS part of the code, but I'm not sure ...

Managing errors in jQuery.ajax() when it encounters a problem

Having a php file with a form that is submitted through jQuery.ajax(), I encountered an issue where the error message was not displayed if the email failed to send. $(document).ready(function () { $('input[type="submit"]').click(function () ...

Trouble reading property 'map' in a react-redux todo application

Greetings! I am currently in the process of developing a to-do list application, but I have encountered the following error: TypeError: Cannot read property 'map' of undefined Below is the code snippet where the error occurs: 4 | function T ...

Align a div to the center horizontally at the top of the screen

Is there a way to vertically center text within a div and also horizontally center the div at the top of the screen? Visit this link for more details <div id='custom'> example text </div> #custom{ width: 50%; background: #FF00 ...

Using CSS to place the h1 text on top of an image

I need some advice on how to place a heading above an image. I have tried using negative margin and adjusting z-index, but the image still covers the heading. If you have a better solution, please let me know! Thank you in advance for your help! PS: Anot ...

Guide on updating directory images by uploading a new one directly onto the site

As someone who is new to HTML, I have a question about updating images on my website through an "admin" page. Currently, I have two websites set up - the main site displays an image from the "images" folder, and the second site serves as an admin page. M ...

Utilizing jQuery's .clone() function to duplicate HTML forms with radio buttons will maintain the radio events specific to each cloned element

I'm currently developing front-end forms using Bootstrap, jQuery, HTML, and a Django backend. In one part of the form, users need to input "Software" information and then have the option to upload the software file or provide a URL link to their hoste ...

Validating dynamic textboxes in Angular with custom rules

Creating dynamic textboxes with *ngFor in Angular <tr *ngFor="let computer in _Computers; let i = index;"> <td>{{computer.Name}}</td><td>{{computer.Optional}}</td> <td> <input matInput [formControl] = " ...

My current objective is to extract the information from a specific item within a combobox by implementing the following code

alert($("select[name="+this.name+"] option:selected").text()); However, I am not receiving any output unless I explicitly specify the name of the combobox instead of using this.name. This issue may be related to the way quotes are being handled. ...