What is the best method to insert a single elongated scrollable image in HTML and CSS?

(Novice inquiry) Greetings, I am endeavoring to design a website featuring a single elongated image as the background that can be scrolled. Nothing too intricate, just an image measuring 1920x3740 pixels where only a portion equivalent to the viewport size is visible. To better illustrate my concept, I have included a visual reference here: https://i.sstatic.net/L9BtN.png

I experimented with stacking multiple divs vertically, each set at 1920x1080 dimensions, and attempted to slice the image accordingly so it fits properly. While this method yielded some success, the images didn't maintain a consistent 16x9 aspect ratio, causing misalignment at the edges. Currently, I have managed to create one large image but am unable to scroll through it.

Here's the HTML code snippet:

<div class="bgImageFull"></div>

Corresponding CSS styling:

.bgImageFull{
  background-image: url(../images/LandingPage/NEW_TAHIN_IMAGE_FULL.jpg);
  height: 100%;
  width: 100%;
  background-repeat: no-repeat;
  background-size: cover;
}

Prior settings are included below, although I suspect they may not address my current dilemma:

*{
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}

html, body{
  height: 100%;
  font-family: 'functionPro';
}

Answer №1

.bgImageFull {
    background-image: url(../images/LandingPage/NEW_TAHIN_IMAGE_FULL.jpg);
    height: 3740px;
    width: 100%;
    background-repeat: no-repeat;
    background-size: cover;
}

It's possible that specifying a height of 100% could be causing the issue you are experiencing.

To avoid this, consider setting the actual height of your image within its class. Using a generic percentage may lead to unexpected results based on its parent element's size.

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

Bottom div refuses to adhere to the bottom of the page

I need help with creating a footer div that sticks to the bottom, left, and right of the page. The current footer doesn't extend all the way down and left. How can I resolve this without using "position: fixed;"? Below is the code snippet (I have rep ...

Is it possible to manipulate the carousel image within the div element?

I am working on a Bootstrap code snippet that showcases an image using the w-100 class to span the full width of the page. However, the challenge I'm facing is making sure the image is visible to users while keeping it small enough so they won't ...

Is Dynamic CSS causing caching issues?

I have implemented an HttpHandler to dynamically adjust CSS (specifically colors) based on a technique I discovered on SO. Everything is working perfectly, except for the page where users can customize their own colors. When they save their preferences an ...

Collapsible Span with Maximum Width in Unique Twitter Bootstrap

UPDATED If I assign a max-width value to the .container element, it disrupts the alignment of my spans. <div class="container" style="max-width:940px"> <div class="row"> <div class="span4" style="background-color:#F00">1</div& ...

Steps to create a fixed navigation bar at the top of the page

Is it possible to create a navigation bar that remains fixed at the top of the page? I'm not referring to using the "position: fixed;" property... The issue with my current navbar is that when zooming out, it loses its position at the top... How ca ...

The CSS grid-template-area feature is not functioning properly in web browsers

Struggling with creating a responsive CSS grid layout for different screen sizes. I want to have five divs on desktop screens and adjust the layout for smaller screens. As a newbie in web development, I'm finding it challenging to get it right. .fir ...

Ways to retrieve content from a div by its class name and then add it to another div with a different class name

I am currently working on customizing the layout of data retrieved from a plugin on my WordPress page. Specifically, I want to rearrange elements within a div with the class name IDX-columnThree (containing price & address data) and move them to another di ...

Having difficulty retrieving information from the interactive spreadsheet

I am encountering an issue while trying to retrieve the values from Handsontable, and the error message displayed is: Uncaught ReferenceError: hot is not defined Despite having defined hot variable, I am puzzled as to why this error is occurring. Below i ...

Interactive dropdown menus using HTML and jQuery

My goal is to dynamically update a group of select boxes when another select box is changed. The challenge I'm facing is getting some of the select boxes to have the same options while allowing for the user to add more selects as needed. There will b ...

Ways to implement pseudo classes to display title text upon button click

Is it possible for the user to input their name and have it appear on the screen once they click the save button? I am using Mantine design framework and want to utilize pseudo classes. However, styling two classes at once seems tricky in Mantine compared ...

What is the best way to apply custom css to a Google Plus share button within an iframe?

I am having an issue with the CSS on my share button. The Google style is causing my CSS to reset. Here is the iframe code I am using: <iframe src="https://apis.google.com/u/0/_/+1/fastbutton?usegapi=1&amp;size=tall&amp;origin=http%3A%2F%2F ...

Store the JavaScript code produced by a php function in a php variable, and display it on an html page without running it

The PHP function I am working with is as follows: <?php function searchbox_markup(){ $baseUrl = "example.com"; ?> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "WebSite", "url": "<?php echo $bas ...

What could be causing the "undefined array key" error message to appear when attempting to retrieve values from HTML forms?

Here are samples of my HTML and PHP code, along with the error message I receive when attempting to run the code in order to retrieve values from an HTML form into my PHP document. For this task, I am utilizing the XAMPP server. I followed the instruction ...

Switch between showing and hiding a div by clicking on an image

Currently, I am experimenting with the toggle div function and utilizing images as triggers for toggling. For instance, when a div is closed, an image of a "plus" sign indicates to the user that it can be expanded, and vice versa for compressing the div. T ...

The Chart.js donut chart is not displaying as expected on the HTML page when using

My HTML code is set up to display a donut chart with database records retrieved through a PHP script. The data is successfully fetched and visible in the browser console, but the chart itself is not showing up. How can I resolve this issue? console.lo ...

Adjust the width of the table's td elements

I am looking to create a table similar to the one shown above. Here is my implementation. Please review my JSFiddle. HTML: <table border="0" id="cssTable"> <tr> <td>eredgb</td> <td><a href="self">0 ...

Tips for targeting a specific set of elements in codeBehind within Web Forms without creating an additional wrapper element

In my Webform page, I have a html form containing fields for customer data and product data, as well as other miscellaneous fields. I am facing the challenge of needing to hide either the group of product fields or customer fields during PageLoad or other ...

The appearance of my sidebar items' right border varies depending on the web browser being used

My sidebar item's right border appears differently in Mozilla and Chrome. How can I resolve this issue? Here are the images from both browsers: https://i.stack.imgur.com/YGkkz.png https://i.stack.imgur.com/JxNs3.png "use client"; import { ...

Here is an example of how to transfer a value from PHP to a jQuery function in the code snippet provided

This is an example of my code. It is functioning properly even without passing a value. function displayMessage(text) { alert(text); } <button type="button" id="button" class="btn btn-success" onclick="displayMessage("Hello");"> Click Me </ ...

The back button functionality in Android cannot be altered or overridden using JavaScript

Hey everyone, I'm currently in the process of developing a mobile application using phonegap. I'm facing an issue where I want to disable the functionality of the back button from navigating to the previous page. I simply want it to do nothing or ...