Continue scrolling down until the bottom of the page touches the top

I am currently working on a portfolio project where I want the page to scroll all the way down until the footer image aligns perfectly with the top image. This will create a seamless merging of the header and footer images.

Despite searching extensively on Google and Stack Overflow, I have not been able to find a solution that achieves this desired effect.

UPDATE

I have made some style adjustments.

While the scrolling functions properly in IE9, it does not work as expected in Google Chrome. Any suggestions on how to address this discrepancy? Thank you

UPDATE 2

Although I have successfully implemented smooth scrolling, I am encountering height-related issues during web browsing.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Portfolio | S.H. MOKHTAR | 2011</title>
        <link rel="stylesheet" type="text/css" href="layout/styles.css" />


    <script>
    function pageScroll() {
        window.scrollBy(0,60); // horizontal and vertical scroll increments
        scrolldelay = setTimeout('pageScroll()',50); // scrolls every 100 milliseconds
    } 

    function stopScroll() {
        clearTimeout(scrolldelay);
    }

    </script>  

    </head>

    <body>

        <div id="header"></div>
        <div id="content"><input type="button" onClick="pageScroll()" value="Scroll Page">
    <a href="javascript:stopScroll()">Stop Scrolling</a><br>
    <br>
    </div>
        <div id="footer"><img src="layout/images/bot.png" style="width:auto; height:auto" /></div>
</body></html>


body, html, div, input, footer{
margin: 0;
padding: 0;
border: 0;
outline: none;
}
body{
    width:100%;
}

#header{
    background:url(images/top.png); height:auto; width:auto; background-repeat:no-repeat;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 43px;
}

#content{
    margin-top:50px;
}

#footer{height:870px;
}

UPDATE 3

Thanks to some assistance, I was able to resolve the height issue. The updated code is now available for download at or can be viewed live at .

You can also check out my other question where I received help with this problem: Height different in IE FF Chrome

Thank you

Answer №1

I have not yet tried this out, but it may look something like the following:

$("document").ready(function(){
  $("window").scrollTop($("#yourimage").offset().top);
});

(Using jQuery for compatibility across different browsers)

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

Exploring Rails 6: Enhancing Web Design with CSS Image Display

I've been attempting to update my webpage background with an image through CSS, but I'm struggling to reference one of my Rails 6 images in the process. Despite trying options like asset-url and image-url, I haven't been successful. However, ...

Configuring lazy loaded modules with Angular 2 router

I am in the process of developing a service that utilizes router configuration to generate a map of routes based on components. Everything works smoothly except when dealing with lazy loaded module routes. I'm stuck on how to retrieve routes from a l ...

I am struggling to make callback functions function properly with an ajax GET request

I'm struggling to extract specific elements from a JSON file retrieved from an external REST API and store them in a local dictionary variable for use in my JavaScript code. While my AJAX GET request is successful, I'm facing an issue where I can ...

Display an image in response to a button click using JavaScript

I am currently working on a feature that will display information when a radio button is pressed. I also want to include an image, but I am facing an issue where the text displays correctly but the image does not appear. What steps should I take to resolve ...

How can you properly structure chainable functions in Angular?

Recently, I've been working on developing custom functions for my Angular application. Following the official guidelines, I have created an independent library. My goal is to create chainable functions similar to this: var obj = { test : function( ...

Locate the final element within an array using JavaScript

Provided with a file path like new/lib/java.exe, I am looking to eliminate the root folder 'new' and structure the new path as lib/java.exe. Challenge: After my attempts, I am left with the path as lib/java.exe/ which includes an unwanted "/". I ...

Having issues with my custom AngularJS directive functionality

app.directive("myData", function() { return { templateUrl: '/my-data.html' }; }); my-data.html file code <tr ng-repeat="employee in employees"> <td>{{employee.id}}</td> <td>{{employee.name}}</t ...

What methods does React Router use to extract typed parameters from path strings?

(This question is about understanding functionality, not asking for a step-by-step guide) While using React Router, I noticed that Vscode IntelliSense can offer strongly-typed suggestions when I input parameters in a route like this: <Route path=&apos ...

The webpage is failing to refresh even after using history.push()

While working on my React dictionary project, I encountered an issue with React Router. After using history.push() with the useHistory hook from react-router, the page does not re-render as expected. I have a search bar and utilize this function to navigat ...

Displaying parent component when URL changes in Vue Router for child components

Currently, I am delving into the world of Vue and encountering an issue with nested routers. Despite defining some child routers in the routes, whenever I access the child route, the parent component continues to be displayed. Below is the snippet of my co ...

Node.js is facing a problem with its asynchronous functionality

As a newcomer to node, I decided to create a simple app with authentication. The data is being stored on a remote MongoDB server. My HTML form sends POST data to my server URL. Below is the route I set up: app.post('/auth', function(req, res){ ...

Why is Three.js r70 only rendering the first plane when merging multiple planes together?

Combining multiple planes into one only results in rendering the first plane. I'm attempting to merge planes together to optimize performance as I intend to render a minimum of 4096 planes at once while minimizing draw calls. Currently utilizing Thre ...

What strategies can I use to successfully navigate through this component?

I'm looking to display "favorite" items within my favorites component. However, I'm facing a challenge since I can't directly pass the postList component to the favorites component. Essentially, I aim to showcase these favorite items on ano ...

Tampermonkey only allows jQuery Click to execute once within a for loop

Attempting to switch the content of a text area to different cars and then trigger a button click to perform an action, repeating this process for each car until all cars have been processed. var index; var cars = ["car1", "car2", "car3"]; var x = documen ...

What could be the reason for the d-flex class in bootstraps preventing my div from expanding to 100% width?

I have a div where I need to display two elements next to each other: a search input field and the corresponding submit button. My attempt so far was to achieve this using the following code: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn. ...

Span element hides the text in the background

Is there a more efficient way to accomplish this task? My current approach involves creating a slide-in background color effect when hovering over a link. However, I am encountering some difficulties with the CSS implementation. In my setup, each link cont ...

Display the final submenu of the Asp.net menu on the right side

The asp.net menu on my website is functioning properly with one exception: the last submenu does not change direction from left to right, and its content is getting cut off at the edges of the screen. This issue is particularly noticeable in the Master pa ...

Can anyone provide guidance on utilizing libraries within a Chrome extension?

I have been attempting to implement this for a total of 10 hours and I am struggling to make it work in script.js. // Creating a button element const button = document.createElement('button'); button.textContent = 'copy'; button.addEve ...

Using double quotes when adding HTML5 local storage entries

Currently, I am setting the value of a field to a variable like this: newUser = document.getElementById('userName').value; Then putting that variable into local storage: localStorage.setItem('userName', JSON.stringify(newUser)); Fet ...

Ways to determine if an object contains an array

Looking at the following data structure: [ 13, { a: [ [ '2988.30000', '0.19000000', '1549294216.653040' ] ] }, { b: [ [ '2988.30000', '0.00000000', '1549294216.653774&a ...