Dynamic website featuring fixed background with content transitioning through clicks or scrolls

Seeking a template or tutorial on how to create a website similar to the following examples:

The desired website layout would allow users to scroll through content while keeping the background neutral, with the option to click links that transition to new content but maintain a stationary background.

I have designed a portfolio site for myself with this effect in mind, however I am unsure of what it is called so I can learn how to code it. The main page would feature content with links on the right side, and as you scroll or click a link, the content smoothly transitions while the background remains fixed.

Hopefully this question is clear! Thank you!

Answer №1

When tackling your question, I typically approach it by stacking divs using the position: absolute property on top of each other. By toggling the active class, the visible element can be identified - ensuring that this class has a higher z-index value than the stacked elements. To set the initially visible element in HTML, simply add the active class to it. Subsequently, utilize JS to toggle the active class for elements. In my JS implementation:

jQuery: https://jquery.com/download/
jQuery Mouse Wheel Plugin: https://github.com/jquery/jquery-mousewheel

HTML:

<div class="container">
    <div class="vertically-stacked active"> //first visible banner
        <h1>Hello</h1>
    </div>
    <div class="vertically-stacked">  //visible only if class active is added
        <h1>World</h1>
    </div>
</div>

You may have an infinite number of vertically-stacked elements.

CSS:

.container    //container of vertically stacked elements
{
    position: relative    //or absolute but not static 
}

.vertically-stacked
{
    left: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    transition: all .25s;   //time which takes to switch the active element
    -moz-transition: all .25s;
    -o-transition: all .25s;
    -webkit-transition: all .25s;
}

.vertically-stacked.active
{
    opacity: 1;
    z-index: 100;
}

JS:

$(document).on('mousewheel', function (e)
{
    var $verticallyStacked = $('.vertically-stacked'),
        oldActive = $verticallyStacked.index($('.vertically-stacked.active')),
        newActive;

    $verticallyStacked.eq(oldActive).removeClass('active');
    if (e.deltaY < 0) //scroll down
    {       
        newActive = oldActive + 1;
    }
    else //scroll up
    {
        newActive = oldActive - 1;
    }
    $verticallyStacked.eq(newActive).addClass('active');
});   

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

Using React Material UI icon within an auto complete feature

https://i.stack.imgur.com/W3CmF.png I am struggling to incorporate the target icon into the autoComplete component. After reviewing the documentation, I have been unable to find a solution. In TextInput, a similar outcome can be achieved by implementing ...

Incorporate a delay when using jQuery's mouseenter function

I'm trying to implement a tooltip that appears 5 seconds after the mouse enters. Here's the code I've been working with: $('thead').mouseenter( function() { var tooltip = $('<div id="tooltip" class="tooltip-container ...

"Utilize AngularJS JavaScript to nest HTML elements within each other for dynamic web

I have developed a unique custom directive called hero. My goal is to set up a nested view for multiple instances of hero. Check out this demo to see it in action. The desired layout looks something like this: <hero a="1"> <hero a="2"> ...

The animated Ajax loader image is not showing up on Internet Explorer 8

After reading numerous posts, none have been able to solve my issue. To address the problem, I included an IMG tag with a style attribute (visibility:hidden) for an ajax loader gif on the page. Additionally, event handlers were added for two jQuery ajax e ...

Could the addition of iframes enhance the efficiency of websites containing a vast amount of DOM elements?

When dealing with websites that have a massive amount of DOM elements, could there be any performance advantages to displaying some content within an iframe? For instance, the project I am currently involved in features a large HTML-based tree structure ...

The JavaScript code that added links to the mobile menu on smaller screens is no longer functioning properly

I recently created a website with a mobile navigation menu that should appear when the browser width is less than 1024px. However, I used some JavaScript (with jQuery) to include links to close the menu, but now the site is not displaying these links and t ...

Encountering a 'Cannot Get /' Error while attempting to reach the /about pathway

I attempted to create a new route for my educational website, and it works when the route is set as '/', but when I try to link to the 'about' page, it displays an error saying 'Cannot Get /about' Here is the code from app.js ...

Comparing `$(window).scroll(fn)` with `$("html,body").scroll(fn)` shows the different ways to

My go-to method for getting or setting the scroll offset in a cross-browser way is: $(window).scrollTop() as a getter, and $('html,body').scrollTop(offset) as a setter. However, I'm unsure about the proper approach for handling the scroll e ...

Stop AJAX from Sending Cookies

When using a web service invoked from a script, I have noticed that even if no cookie information is needed, the cookie is still sent along with each request. While I understand that cookies are typically sent by default in HTTP requests, is there any way ...

Query inputting time displaying additional numerical values beyond just minutes

I am adding a time field to a table with a length of 6 in the database. Utilizing the Tempos Dominus Bootstrap library for the time within the form HTML Form <div class="form-group"> <label for="time">Hora</label> ...

Instructions for instructing Codeception to finalize the selection from a dropdown list without the need to click on a submit button

I am facing an issue where I am able to select an element from a drop down list in codeception, but it is not being displayed as selected in the box. I believe the select operation is not completing properly. Since there is no submit button available, I at ...

Tips for managing ajax responses using jquery

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> $(document).ready(function(){ $("#submit").on('click' ...

Can an enterprise level web application be effectively built using [HTML5 + jQuery] (without ASP.NET) + WCF?

We have been utilizing ASP.NET web forms for a long time to get some perspective. While we understand the advantages of MVC over web forms, there's now a suggestion on the table to skip all abstraction layers and move directly from a pure .HTML page ...

Adding the most recent version of jquery causes the webpage to malfunction

Currently, I am facing a challenge on a website that has an outdated version of jQuery (1.7.2) included in the header. In order to use a plugin that requires the latest version of jQuery, I tried linking the newer version (2.1.3) in the footer. However, j ...

Ways to access every iframe on a webpage

I am facing a challenge with a highly intricate HTML page. <html> <head></head> <body> <iframe> A </iframe> <table> <div> <span> <div> <iframe ...

Chrome distorts background images with CSS when resized

One thing I noticed is that Chrome seems to display CSS background-images differently compared to using the <img /> tag. I tested two identical images resized to the same dimensions The first image set as a CSS background-image appeared pixelated W ...

Implement two different styles within an element's style properties

Welcome everyone, I have a question regarding adding marquee effects to a table row along with highlighting it. Is it possible to include moving text from left to right in the same active row? For example, let's say that the current time is 12:45 AM. ...

Transferring files to Django using AJAX

I am struggling with the process of uploading files to django using ajax. The upload is done within a modal window. The Form <div class="modal fade bs-example-modal-lg" id="fileUploadModal" role="dialog" aria-hidden="true"> <div class="modal ...

Prevent EditFor() from being used in MVC depending on a certain condition

I'm currently working with MVC 4 Within my *.ascx page, I have the following code snippet to display a textbox: <div class="editor-field inner"> <%: Html.EditorFor(model => model.Number) %> </div> The model includes a bo ...

An unexpected problem with text redirection that should not be happening

I am facing an issue with my HTML text field and post button on my website. Whenever I click the post button to make a post, it redirects to a separate PHP file called post.php which handles PHP and MySQL code for posting. However, I want to avoid this red ...