Zooming on a webpage is causing problems

One issue I'm facing is with the elements on my page acting strange when I zoom in and out.

Everything seems to be working fine except for a container div that should overlay a color over the image background. When I zoom in or switch to mobile view, the div does not extend all the way to the bottom of the page as it should. Instead, it only shows the background image at the bottom without the color overlay.

Here is the code snippet:

#container {
  height:100%;
  width:100%;
  position: relative;
  background-color: rgba(0,0,0,.5);
  position: fixed;
}

body {
  background-image: url(../img/d2.jpg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

HTML:

<div id="container">
    <div class="block">
         Content
    </div>       
</div>

I've already attempted using the 100% height property on the overlay, but it didn't resolve the issue. This problem becomes more apparent on mobile devices.

Answer №1

The issue may lie in the method you are currently using. Your CSS indicates that the container has a height and width of 100%, but depending on how your HTML is structured, the container may only extend to 100% of the browser window rather than the entire webpage.

Answer №2

Following Oscar's advice to fine-tune your CSS is a great first step. After making those adjustments, it appears that everything is functioning properly, although I still have some uncertainty about the issue at hand.

#box {
  height:100%;
  width:100%;
  position: relative;
  background-color: rgba(255,255,255,.8);
  position: absolute;
}

html {
  background-image: url('http://www.example.com/image.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

JSFiddle Link

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

Monitor Socket IO for client disconnection events

I am facing an issue where I need to identify when a user loses connection to the socket. It seems that socket.on("disconnect") is not triggering when I simply close my laptop, leading to the ajax call not executing to update the database and mark the us ...

Tips for activating Vue.js production mode with webpack 2.7

I have encountered performance issues with Vue.js in my existing code base. Additionally, I noticed a notice in the browser console: https://i.sstatic.net/KY1B3.png So, I believe that one simple solution could be to switch Vue into production mode. Foll ...

Dealing with a socket.io CORS problem

After deciding to implement a websocket on my website, I opted to utilize the socket.io library. However, I've encountered a CORS error: Access to XMLHttpRequest at 'http://localhost:2021/socket.io/?EIO=4&transport=polling&t=NlbFGS2&apos ...

Tips for generating and invoking a promise within NodeJS

I have been attempting to access Firestore using a function I created that includes a collection variable. var fetchDataFromFirestore = function(collection, doc){ return promise = new Promise(function(resolve,reject){ //If doc param is null Quer ...

Mixin for conditional input styles in Sass

I am interested in developing a conditional sass class that can be customized based on an argument provided. I am unsure about the terminology for this feature. For instance: <img class="width-200" .../> I would like to create a sass mixin that tak ...

What is the best way to transfer form data stored locally to a Django view and then store it in the database?

Is there a way to transfer form data from an offline website to a Django view for database storage? I want to fill out a form, save it in local storage, and then upload the data to the database when I reconnect to the internet. Is there a tutorial or can ...

Using a JavaScript function inside a loop without the need for a click event

I have successfully created a slideshow, but I am facing an issue with looping it continuously. Currently, I have implemented a click event to restart the script, but I want it to loop without the need for any interaction. window.CP.exitedLoop(0);functio ...

Executing a Databind function using the keypress method in jQuery

On my simple page, I have a repeater being populated by a C# databind method. The page includes a search textbox that performs real-time searching as you type. This functionality is achieved by utilizing the rowfilter in the databind method to filter the r ...

What could be causing the JQuery date picker to fail to load on the initial ng-click event?

I am encountering an issue with a JQuery UI date picker that is loaded through ng-click using the code below: Input: <input type="text" id="datepicker" autocomplete="off" ng-model="selectedDate" ng-click="showDatepicker()" placeholder="(Click to sele ...

chrome side column must be set to 100% height

Having trouble with setting height to 100%. I have a list of items that need to be distributed to match the height of the side image. It works fine when I use a fixed height, but not with a percentage. The issue arises because the website is responsive a ...

Perform multiple function invocations on a single variable using JavaScript

Is there a way to execute multiple functions on a single object in JavaScript? Maybe something like this: element .setHtml('test'), .setColor('green'); Instead of: element.setHtml('test'); element.setColor('gre ...

Executing a command efficiently in Javascript with the get method

The command that needs to be sent to the embedded device is in the form of a GET method. However, the value continuouspantiltmove: String(pt) is not being properly transmitted to the CGI script through Google Chrome, causing it to fail. Since I do not hav ...

Utilizing flex-box for smooth transitions in React Router with react-tranisition-group

Currently, I am working on implementing transitions for my react-router page using react-transition-group. All of my page content is wrapped inside a container, and I have applied flex-box to center the container. Unfortunately, I am facing issues with g ...

Ways to animate elements while scrolling in React.js?

I am new to using React.JS and currently working on setting up an E-commerce Store. My goal is to have 5 images stack on top of each other and move together as the user scrolls. I used to achieve this effect in Vanilla JavaScript by adding a window.addEven ...

Building a Meteor query in MongoDB using $in operator while handling duplicate values

I have a collection of songs that I want to present to a user. Each song is associated with a specific id. The issue I am encountering is that some songs should be displayed multiple times. Currently, I am using the $in operator in my MongoDB query, but it ...

I am experiencing difficulty with loading the local images stored in the /public/images directory of my React app

I am currently working on a component called Portafolio.js where I am utilizing the map function to retrieve each object from a file named "trabajos.js" that contains all the objects with their respective properties. My goal is to display an image for each ...

Apply the CSS rule specifically for desktop screens, excluding mobile and tablet devices

My website has a logo in the header that appears too small on computer screens. I came across a code snippet that allows me to increase the size of the logo, but I only want this change to be applied on computers and not on mobile or tablet devices. The co ...

The dynamic sidebar menu in Adminlte 3 with bootstrap-4 loaded from ajax is not functioning properly, presenting issues with sidebar

Is there a way to fetch dynamic sidebar menu data from the database using AJAX in the adminlte 3 dashboard along with bootstrap 4? I have tried loading the sidebar menu data dynamically using AJAX, but the sidebar open/close functionality is not working pr ...

Trouble sliding with Material UI Slider

I've encountered an issue with my Material UI slider - it doesn't slide when clicked and dragged. I followed one of the examples on the Material UI website (https://material-ui.com/components/slider/) and included an onChange function. The values ...

Arranging progress bars between various nodes using HTML and CSS

I am currently facing a challenge in creating a stepping wizard form layout that features a bar at the top of the page. This bar displays a dynamic number of steps (nodes) and progress bars that connect these nodes. However, I am encountering difficulties ...