Ensure that the content remains at the center of the screen, but is dynamic and changes

I have a unique concept I want to experiment with, but I'm unsure of the best approach to take.

My idea involves centering content on the screen and instead of having it scroll off and new content scroll in, I would like it to stay centered and smoothly transition into the next content.

For example, when the user scrolls to "Content 1," it locks that content in the center of the screen. As the user continues to scroll, "Content 1" fades into "Content 2," creating a seamless transition effect. When the user scrolls past "Content 3," the scrolling behavior returns to normal.

I'm looking to achieve this using vanilla JS and CSS, ensuring that it works smoothly on both mobile (touch) and desktop (wheel) devices.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" integrity="sha512-wnea99uKIC3TJF7v4eKk4Y+lMz2Mklv18+r4na2Gn1abDRPPOeef95xTzdwGD9e6zXJBteMIhZ1+68QC5byJZw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<p>Normal scrolling content</p>

<div class="min-h-screen flex justify-center content-center items-center">
<h2>Content 1</h2>
</div>

<div class="min-h-screen flex justify-center content-center items-center">
<h2>Content 2</h2>
</div>

<div class="min-h-screen flex justify-center content-center items-center">
<h2>Content 3</h2>
</div>

<p>Rest of the normal scrolling content</p>

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

jQuery tabs become non-functional following submission of form

I have a form contained within a jQuery tab div that is loaded using AJAX: <div id="tabs-2"> <form id="frmLogin" name="frmLogin" class="cmxform" method="post" action="actions/login.php"> <p> <label>Username& ...

What is the most efficient method for managing axios errors in Laravel and Vue.js?

Currently, I am developing spa web applications using Laravel as the backend and Vue.js as the frontend framework. For authentication with API, I am utilizing Laravel Passport, and for managing my application state, I am using Vuex. Initially, I created A ...

Display or conceal a vue-strap spinner within a parent or child component

To ensure the spinner appears before a component mounts and hides after an AJAX request is complete, I am utilizing the yuche/vue-strap spinner. This spinner is positioned in the parent days.vue template immediately preceding the cycles.vue template. The ...

When using jQuery's .each method, only the final JavaScript object element is added to the divs

I have a unique set of dynamically-created divs, each containing a Title. When a div is clicked, a modal opens (which is cleared upon click), and the Title is displayed again in the modal. My goal is to add the category descriptions into these modals, but ...

adjust the size of the textarea to perfectly fill the available space

I want my textarea within the wrapctxt container to always fill up the remaining space below the wrapctop section, reaching the bottom of the wrapc element. .panelb{ display:grid; grid-template-columns: 130px 34% auto; height:100vh; width: ...

What is the process for changing a jQuery countdown function to a count-up function?

I'm currently developing a portal that utilizes a jquery plugin known as countdown from the link https://github.com/hilios/jQuery.countdown Here is the code snippet: $(document).ready(function(){ $("#countdown").countdown("2022/06/25 ...

I am looking to retrieve the values of checked checkboxes in a MUI multi-select component

I am currently using Material-UI's mui multi select component and I need to determine whether an item is selected or unselected in order to set the correct state value. I have checked the event.target but it does not seem to have a checked attribute. ...

Array not transmitted via jQuery ajax

I am attempting to use the jQuery ajax function to send an array, but for some reason it is not functioning as expected. Below is the code I have been working with: if (section_name == "first_details_div") { var fields_arr = ["f_name", "l_name", "i ...

Adjust the size of the container DIV based on the content within the child DIV

I have been searching for a solution to my question without success. Here is the issue: I have a DIV that acts as a container for a Post in my project. Inside this post are classes for the poster avatar, name, timestamp, text, and more. The problem arise ...

The session variable is not accessible in an AJAX function

Currently, I am working on a PHP project where I am inserting values into a database. To achieve this, I am utilizing the Ajax method. The process involves calling an Ajax function on button click, which then triggers another PHP file responsible for the ...

Due to a glitch in the firebase cloud function, the payment is not going through

I have developed a react-redux application with Firestore as the database and now I want to integrate Firebase Cloud Functions to handle Stripe payments. Here is how it's set up: Below is the action method for checkout, which processes token and amo ...

Exporting a VueJS webpage to save as an HTML file on your computer

Scenario: I am working on a project where I need to provide users with the option to download a static export of a webpage that includes VueJS as a JavaScript framework. I attempted to export using filesaver.js and blob with the mimetype text/html, making ...

Kudos to the information provided in the table!

My JSON data is structured like this: { description : "Meeting Description" name : "Meeting name" owner : { name: "Creator Name", email: "Creator Name" } } I want to present the details in a table format as follows: Meeti ...

What is the best way to pass an array as a parameter in Angular?

I have set up my routing module like this: const routes: Routes = [ { path: "engineering/:branches", component: BranchesTabsComponent }, { path: "humanities/:branches", component: BranchesTabsComponent }, ]; In the main-contin ...

Is there a way to trigger a click event on an href using asp code behind?

Is there a way to programmatically trigger a click event on the href "shipping_question_ID_product_received_as_ordered_link" from the code behind of an ASP form? This href triggers a complex function in jquery when clicked by the user. I need to simulate ...

Value of an object passed as a parameter in a function

I am trying to use jQuery to change the color of a link, but I keep getting an error when trying to reference the object. Here is my HTML : <a onmouseover="loclink(this);return false;" href="locations.html" title="Locations" class="nav-link align_nav" ...

I successfully developed a unique custom accordion feature in React.js, where the toggle functionality is fully functional. However, I am currently facing an

import React, { useState, useEffect } from "react"; import axios from "axios"; const Faq = () => { const [faq, setFaq] = useState([]); const [activeIndex, setActiveIndex] = useState(null); const fetchFaqs = async () => { ...

Achieve Custom Styling in Material UI Stepper Label with ReactJS: Adjust Font Size and Margin Top

Is there a way to adjust the fontsize of the stepper label and the margin between the label and circle? The default marginTop is set to 16px, but I would like to reduce it. Any suggestions on how to achieve this? Check out the Codesandbox code using Mater ...

Utilizing React Router with HTML5 pushstate in conjunction with Nginx servers

I am working on a React app with react-router and HTML5 pushstate routes. I want to use http://example.com/v2 as the base route for serving my new website. Below are the nginx configurations that I am using: This configuration is designed to catch reques ...

What is the best way to show the result of a PHP form in an HTML page when the PHP processing is on a different page, without relying

Imagine having a form located in the file called form.php. <form action="process.php" method="POST"> <input type="text" name="message"> <input type="submit" value="Submit"> </form> <span class="result"></span> The proc ...