Struggling to remove excess space at the bottom of an HTML page using CSS styling

After successfully centering a page with CSS, I am now faced with an issue of excess space at the bottom that I can't seem to eliminate. If anyone could take a look at my webpage hosted for free here: , it would be greatly appreciated.

Below is the CSS code I used in attempting to center the page:

html, body 
{
    padding: 0;
    margin: 0;
}

#container 
{
    width: 700px;
    margin: 0 auto;
    text-align: left;
}

Answer №1

The reason for this behavior is due to the use of relative positioning to stack elements on top of each other. While they visually appear in a different location, they still occupy space within the document flow where they were originally placed.

To avoid this issue, opt for absolute positioning to remove the elements from the document flow entirely.

Answer №2

The issue is related to the background division

<div id="bg"></div>

When the top property is set to -190px, it creates a 190px space at the bottom. To resolve this, adjust the margin-bottom property to -190px for that specific division.

Answer №3

A more streamlined approach would be to style the outermost elements in the following manner:

body
{
    padding: 0;
    margin: 0 auto;
    width: 700px; /* Using pixels here for simplicity */
}

#container
{
    position: absolute;
    background: url(images/pixel_down.jpg);
    height: 100%;
}

Remove CSS positioning from all other elements and consider simplifying the navigation bar code by using a straightforward row of images instead.

You might also want to explore hosting options that won't disrupt the layout with excessive advertising. Websites like have been known to offer ad-free solutions, although it's wise to confirm their current policies.

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

Removing the new line using v-if in Vue.js

I want to insert a v-if in the middle of a sentence without creating a new line. This is what I desire: A / B / C / D However, my current output is: A / B / C / D This is the code I am using: <div> {{ A }} / {{ B }} <p v-if="functi ...

The function was expecting an array for ordering, but instead received an object

I need help filtering my results based on their position. Whenever I try to use the orderBy function, it breaks the page because the result is not an array. How can I fix this issue? I'm currently stuck at this point. This is how I attempt to filter ...

Is there a way to set an absolute placement for <tr> tags within a <table> using Html and Css?

Struggling to position the rows in my table vertically for CSS animations. I'm having difficulty ensuring the correct width for the rows. Here's what I have so far: <!DOCTYPE html> <html> <head> <style> table { ...

Submitting two arrays via form

Having trouble getting a form to submit. The form should allow the user to select a task, then display several rows with checkboxes and dropdown selects with values ranging from 1-10. If a checkbox is selected, the values from the corresponding select sh ...

Effortlessly Display or Conceal Numerous Table Columns Using jQuery

I have a small table where I want to hide certain details with a basic button... for instance, table { border-collapse: collapse; } th, td { border: 1px solid gray; padding: 5px 10px; } <button>Show/Hide Details</button> <table> ...

Styling errors with jQuery validation

How can I remove the borders in ul > li elements? Here is my current setup: errorLabelContainer: $("ul", $('div.error')), wrapper: 'li', errorContainer: $('div.error'), I have tried the following: div.message{ bac ...

Scroll the content within an iframe's page container

Is it possible to scroll the entire browser window to the top when clicking on a link inside the iframe I'm in? I have control over both the page container and the iframe. ...

Show image when hovering over individual words

Is there a way to display different descriptions or images when hovering over each word in a paragraph using HTML? It seems that only the last element is being retrieved and displayed across the entire paragraph. Any suggestions on how to fix this issue wo ...

Enhancing user experience with Bootstrap's body padding and customizable scrollbars

Recently, I encountered an issue with the footer color in bootstrap. To fix this problem, I created a div and removed the extra padding from the body element. You can view the code snippet here: jsfiddle.net/wctGM/9/ However, when viewing the mobile ver ...

Retrieve JSON data by making a POST request to a website's API

Can you help me retrieve Json data from a website API using JavaScript? I'm trying to fetch quotes from the following website: for my quotes generator page. While I have some understanding of making GET requests, it seems that this API requires POST ...

Switching images with Jquery

Seeking help to create an FAQ page using HTML, CSS, and jQuery. My goal is to rotate an arrow when a question is opened and revert it back when another question is clicked. I've successfully achieved this with <p> tags but facing issues with the ...

Collapsed Grid System

Is it possible to create a CSS grid system that meets the following requirements: The grid should have arbitrary height (with consistent width) and when a grid overflows, it should stack vertically underneath the preceding grid, regardless of other grid ...

Possible revision: "Trouble with event triggering when using an anchor tag within an <li> element

I am currently working with a horizontal menu plugin where I am including anchor tags within the <li> elements to create menu items. I have set up an onmouseover event for the anchor tag to display the submenu when the mouse hovers over it. However ...

The concept of setting a value is not defined in JavaScript when compared to

Within my primary python script, the following code snippet is present. @app.route('/accounts/test/learn/medium') def medium(): word = random.choice(os.listdir("characters/")) return render_template('accounts/test/medium.html', word=w ...

Switch out the arrow icon in the dropdown menu with an SVG graphic

Looking for a way to customize the dropdown caret in a semantic-ui-react component? Here's how it currently appears: https://i.sstatic.net/GpvfC.png <Dropdown className="hello-dropdown" placeholder="Comapany" onChange={th ...

Trigger a notification based on the selected choice

Here is some sample HTML code: <div id="hiddenDiv" style="display: none;"> <h1 id="welcomehowareyou">How are you feeling today?</h1> <select name="mood" id="mood"> <option value="" disabled selected>How are you feeling?</o ...

Where exactly is Bootstrap hiding?

Currently, I am in the process of working on a web application using Spring. My goal is to set up a bootstrap test table for the application and apply different themes to it. However, I am facing an issue where Bootstrap seems to be missing. I'm unsur ...

Ensuring proper alignment between labels and input

How can I align a label and a range input field on the same line? I have tried using display: inline-block, but it does not seem to work. There doesn't appear to be any conflicting styles, and all sources indicate that this approach should be effect ...

How can EJS variables be utilized within HTML input fields?

I am facing an issue while trying to use a checkbox to redirect selected users to a new page. I am looking for a solution on how this can be achieved, especially when using mongodb to store the information. Below is my current code snippet: Firstly, I ren ...

Achieving a tidy layout with child divs inside a parent div

I'm struggling to figure out how to arrange objects with margins inside a parent div. Initially, I thought using float would do the trick, but I quickly realized it wasn't the solution. This results in an unsightly amount of space. The divs that ...