Skip to content
Advertisement

How to remove unnecessary space using css?

I made a simple HTML webpage recently, and everything works perfectly, except for on the webpage you can scroll to the right and there’s a strange space where there aren’t any elements and that the background doesn’t cover. I’ve gone over my code many times, but I just can’t figure out what it is.

Screenshot of the problem:

1

As for the code, here it is:

JavaScript

This code doesn’t have the background image in it, so if you want to view that, you can download it here: Click here

Advertisement

Answer

Add this to your css style:

JavaScript

For some reason this is not a default value. This will make all elements width calculated with padding included. Otherwise padding is added to width. Margin is still added on top of width. There is no solution for that.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement