Create a scrolling effect for text using the .animate method

My goal is to craft a webpage reminiscent of this, utilizing a video background that seamlessly transitions as the user scrolls to narrate a story.

Currently, I've managed to get the video to play flawlessly. However, the <div> elements are only displayed one after another stacked below the video. I envision the text smoothly scrolling up from the bottom when the user clicks anywhere on the page until reaching the same position as the previous text, but my implementation of the .animate() function seems flawed.

While this task seems straightforward, my initial attempt is lacking.

fiddle: http://jsfiddle.net/f06w76bv/

<!DOCTYPE html>
<html>
    <head>
    <style>
    .textConatiner{
        position: absolute;
        background-color: rgba(0, 0, 0, 0.9);
        color: #fff;
        left:10%;
    }
    video.bgvid{
        position: fixed;
        right: 0;
        bottom: 0;
        min-width: 100%;
        min-height: 100%;
        width: auto;
        height: auto;
        z-index: -100;
        background: url(TurbineStill.png) no-repeat;
        background-size: cover;
    }
    </style>
    </head>
    <body>
        <video autoplay loop poster="TurbineStill.png"  class="bgvid">
            <source src="Turbine.mp4" type="video/mp4">
        </video>    
        <section>
            <div class="textConatiner" id="one" style="top:50%;">
                <h2>Video Backgrounds One</h2>                          
            </div>      
        </section>      
        <section>
            <div class="textConatiner" id="two" style="top:150%;">
                <h2>Video Backgrounds One</h2>                          
            </div>      
        </section>
    </body> 
    <script src="js/jquery-1.11.1.js"></script>
    <script>
    $(document).ready(function () { 
        $(document).click(function () {
            var myDiv = $("#two");
            var scrollto = myDiv.offset().top + (myDiv.height() / 2);
            myDiv.animate({ scrollTop: scrollTo }, 1000);
        });
    });
    </script>
</html>

EDIT By adding the position to the div container I'm able to get the original div positions exactly where I want them when the page loads. However, I still cannot get the animate method to move the second div into the page from below.

Answer №1

Your inquiry is actually a compilation of multiple questions combined into one.

To address your concern about positioning, you can utilize basic CSS techniques similar to how you would style any other element in the DOM. Detailed tutorials on this topic can be found on websites like W3Schools.

If you are interested in scrolling to a specific element using JQuery, you can refer to a relevant discussion on Stack Overflow.

Furthermore, there is another informative thread on Stack Overflow that covers the concept of moving a video based on scroll behavior, which you can explore here.

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

Removing the `&` sign and any text that appears after it from a URL is a simple process that

Help Needed with URL Manipulation https://myApp-ajj.com/sp?id=cat_item&sys_id=cf9f149cdbd25f00d080591e5e961920&sys_id1=cf9f149cdbd25f00d080591e5e961920&sysp_Id=a691acd9dbdf1bc0e9619fb&sysparm_CloneTable=sc_request&sysparm_CloneTable=sc ...

Why does JavaScript display a width of 800px for the Motorola Atrix MB860 4G? Shouldn't it actually be 540px?

When developing my Mobile Web App, I encountered an issue with getting the screen width of different devices to fit the views dynamically. I am puzzled by the fact that the Motorola Atrix MB860 is reporting a width of 800px despite having a resolution of ...

Save the selected value from the dropdown menu and automatically check the corresponding checkbox when it

I'm attempting to update the 'value' of a checkbox once an item is chosen from a dropdown list and then the checkbox itself is clicked. I have created a jQuery function that captures the value from the dropdown list (I omitted the code for t ...

Codeigniter - Troubleshooting Ajax Post Issues

I'm currently troubleshooting an issue with my ajax function. I have implemented similar code in the past, but for some reason it's not working now. The insert_data function appears to be functioning correctly. I have tested alerting username an ...

Troubleshooting problem with Chrome caused by Ajax-loaded content

When I dynamically load content using the code below, I encounter an issue. $(document).ready(function() { $("#tags").keyup(function(){ var q = $(this).val(); $.ajax({ ...

`Error encountered when attempting to convert date with Angular JS filter`

Utilizing angular js filter in the controller for date formatting. A user selects a date from a uib-datepicker-popup. The goal is to format this date using ISO 8601 (yyyy-mm-dd) date format. Upon logging the user-selected date, the output is as follows: S ...

Differences between Angular's $injector and Angular's dependency injectionAngular

As a newcomer to Angular, I am exploring the use of $injector and its get function to retrieve specific services. For instance: app.factory('$myService', function($injector) { return { ... var http = $injector.get('$http&apos ...

Adjust the camera position in React-VR while swapping out the PanoPopMatrix

I'm new to react-vr and I am working on developing a tour app. My issue is that when I update the Pano pictures, the camera/scene remains in the same position as before loading the new picture. Below is a snippet of the code: render() { if (!this.s ...

The resetFields() function fails to execute

While utilizing Vue3 with Element Plus to create a form, I encountered an issue with the resetFields() method not working as expected. The form is unable to automatically refresh itself. In the child component (Edit.vue): <template> <el-dialo ...

Left-aligned border below titles that are centered

Is there a way to add a small border under a title tag using CSS? I found a solution using :after, but I'm encountering an issue when trying to center the title. h1:after{ content: ''; display: block; height: 4px; width: 60px; mar ...

How to use Bootstrap to center an SVG or div in the middle of the page

I've been struggling to center this box for a week now, but no matter what I try, it keeps ending up on the center left. I attempted to use CSS to position it absolutely, but that ended up messing with the responsive design. Here is my HTML: <body ...

Is there a way for me to smoothly switch between two nuxt pages, pausing for a child component transition or animation to complete before moving on?

Seeking guidance on transitions. Is it feasible to wait for a child transition/animation to finish before transitioning from one page to another? For instance: 1) Home (Page Component) a) Logo (Vue Component) 2) About (Page Component) Upon clicking on ...

What is the mechanism by which sending data directly to the response object displays content to the user?

What exactly does the .pipe(res) segment of the code snippet from that article do at the end of the stream? fs.createReadStream(filePath).pipe(brotli()).pipe(res) I have a basic understanding that the first part reads the file and the second compresses i ...

Is there a way to maintain the original style of an HTML element when printing it?

When attempting to print an HTML element using window.print();, the original style is not preserved. How can this issue be resolved? printInvoice() { var mywindow = window.open("", "PRINT"); mywindow.document.write("<html>"); mywindow.d ...

Limit Google Places auto complete to display only addresses designated for residential use

I'm in the process of developing an application that utilizes the Google Places autocomplete API. However, I specifically want to restrict user input to only residential addresses, excluding businesses and points of interest. Despite going through the ...

Once a dropdown is chosen, the dynamic data in another dropdown should be updated

I am currently working on a project that involves Booststrap, JQuery, Flask, and Jinja. In the project, I have three static dropdowns that I want to convert into dynamic dropdowns. What I aim for is when an option X is chosen in dropdown A, it will modify ...

Prevent a sliding panel from responding if there is no input text by incorporating jQuery

I have a straightforward example of user input and a button that reveals "Hello World" when clicked: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1 ...

The behavior of the jQuery done() function appears to be triggering prior to the request being

I have encountered an issue where an ajax loader is not hiding after a request is done. The problem is that the done() callback is firing immediately after the blur() event, even before the request is sent. To confirm this, I intentionally delayed the re ...

redirecting from an AJAX request

Seeking a way to perform a redirect following an ajax `put` request. My intention is to implement client-side validation using pure JS. Client: $(document).ready(function() { login = () => { var username = $("[name='username']"). ...

What is the best way to implement autoplay sound on a JavaScript webpage?

I'm currently working on a web system aimed at monitoring values from a database, and I have the requirement to trigger a sound alert when a specific range of values is received. Despite trying various examples found online, none of them have been suc ...