Could there be any elements in the code that serve no purpose?

Here is an image of the design I envision.

  1. It will feature a sticky footer that remains at the bottom of the page at all times.
  2. The main content area should adjust its height to fill the space between the header and footer, with a scrollbar appearing automatically if the content exceeds the available space.

** If there are any unnecessary elements in my code, please point them out as I aim for a simple design.

** As seen on JSFIDDLE, the black main content div appears quite short. This issue was resolved by removing the fixed height property, but it now shows up as a small rectangle at the top of the page when there is no content. The desired outcome is for the content to stretch from the header to the footer, scrolling only when needed.

JSFIDDLE

HTML CODE:

<body>
<div id="page">
        <div id="header">

        </div>

        <div id="main">

</div>
        <div id="footer">

        </div>
</div>
</body>

CSS CODE:

html, body
{
        padding:0;
        margin:0;
        height:100%;
}
#page
{
        min-height:100%;
        position:relative;
        height:100%;
        min-width:960px;
}
#header
{
        background-color:#115EA2;
        height:100px;
        width:100%;
        position:relative;
}
#main
{
        width:1300px;
        margin-left:auto;
        margin-right:auto;
        background-color:#F1F2F3;
        /*min-height:100%;
        height:auto;
        height:100%;*/
        margin:0 auto -50px;
        vertical-align:bottom;
        text-align: left;
        color:#115EA2;
        padding: 20px 20px 40px 20px;
        text-decoration: none;
}


#footer
{
        position:fixed;
        width:100%;
        bottom:0;
        height:35px;
        background-color: #115EA2;
}

/* NAVIGATION BAR CODE */
#navigation
{
        min-width:930px;
        position:relative;
        white-space:nowrap;
        padding:65px 0 0 0;
}

Answer №1

Your fiddle has been improved with a suggestion. Having a fixed footer? Consider fixing the header as well to provide a smoother user experience, avoiding the need to scroll up every time they navigate to a different page.

SEE EXAMPLE

Hope this Helps

Answer №2

Check out this link for a solution

Make sure to include overflow-y:scroll; and set a height value such as 100% for your #main element

I have optimized some of the unnecessary CSS, but there may be more that can be removed. Without knowing your specific end goal, it's challenging to determine what else can be modified.

#main {
    width:1300px;
    height:100%;
    background-color:black;
    margin:0 auto -50px;
    vertical-align:bottom;
    color:black;
    padding: 20px 20px 40px 20px;
    text-decoration: none;
    overflow-y:scroll;
}

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

Encountering an unusual hash code when implementing Google Tag Manager in a Next.js project was

I am currently using Next.js and have added Google Tag Manager through a script <script dangerouslySetInnerHTML={{ __html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var ...

What steps can I take to stop my browser from displaying the "waiting for MyHostName" message while performing an ajax Post/Get operation?

Whenever I access a website using Chrome, a message appears in the status bar saying "Waiting for MyHost name" along with an Ajax Loader circle in the browser tab. Here is a javascript function that I am working with: function listen_backend_client_reques ...

How can I set up SASS with automatic refreshing?

Upon running the command npm install sass --watch ... An error is returned, npm ERR! enoent Indicates that npm cannot locate a file. However, the file does exist and all spellings are accurate. Any assistance would be greatly appreciated. ...

Encryption Extensions for Video Content in HTML5

I know this might not be the typical question, but I'm hoping the knowledgeable community here can help me out. After searching high and low on the internet with various search terms, I've yet to find a comprehensive guide on how to actually imp ...

What is the reason for the improper setting of the div position?

Welcome to the interactive Pointer Pin application! The red-bordered box is where you can drop your Pointer Pins. This area has a background image set. The blue-bordered box is where you can drag various Pointer Pins from. These pins can be dropped into ...

What are some ways to adjust the size of the option field in a select menu?

In my ionic popup, I have a HTML property called select with nested options. Below is the code snippet along with the applied CSS. My query is how can I set the white space to occupy the entire area of the select? https://i.stack.imgur.com/iPqAa.png http ...

Move Ext.MessageBox.alert() to a new position in the code without altering its current functionality

I am looking for a way to reposition all Ext.MessageBox.alert() messages throughout our application without directly altering the code in our JSP pages. I can, however, include a JavaScript file. Option 1: I have found that I can reposition a message aler ...

Tips for aligning buttons in a row

I am trying to find a way to make my buttons more compact within a <div> element when the length exceeds 100%. Is there a way to achieve this while avoiding wrapping to a second line? Is there a solution similar to using scaleX, but one that takes i ...

Is it possible to eliminate the table borders and incorporate different colors for every other row?

Eliminating the table borders and applying color to alternate rows. Check out my code snippet: https://stackblitz.com/angular/dnbermjydavk?file=app%2Ftable-overview-example.ts. ...

Increment the counter value by one when a new class is created or appended

My goal is to develop a system that increments the 'fault' counter by one every time a wrong answer is submitted. To achieve this, I have configured my system to detect when a class named "incorrectResponse" is generated. However, I am encounteri ...

Setting the percentage height of parent and child divs in a precise manner

Trying to work through this without causing chaos. I have a container div containing three floated left child divs, with the container div set to 100% height like so: .Container { height: 100%; min-width: 600px; overflow-y: hidden; } One of the child divs ...

Implementing position sticky on a div depending on its content text - step by step guide

If the text inside the .newsDate matches the previous or next .newsDate, I want to make its position sticky when scrolling, until it reaches the next .newsMiddleCont div. What I'm trying to achieve: The same date on multiple news items should s ...

What is the best way to save input field values when a reload occurs before submitting?

html: <form name="shippingForm" class="form-horizontal" role="form"> <div class="form-group"> <p class="control-p col-sm-2" for="Address">Address Line1<b class="h4-color">*</b>:</p> <div class="col-sm-10"& ...

Stopping JQuery ajax calls due to HTTP request for file download

Issue: I am facing a problem on my website where I have two ongoing JQuery ajax long polling calls. I am now working on implementing a file download feature, where users are prompted to save a file when they click on a specific link. The file download fun ...

Tips for aligning a div within a flexbox to the bottom position

I'm having trouble aligning the div at the bottom of the flex box. I attempted to use align-content: flex-end; but it didn't work. Is there a way to keep the <.div class="parameters"> at the bottom of the row? Especially when the ...

ASP.NET Dynamic Slideshow with Horizontal Reel Scrolling for Stunning

I'm curious if there is anyone who can guide me on creating a fascinating horizontal reel scroll slideshow using asp.net, similar to the one showcased in this mesmerizing link! Check out this Live Demo for a captivating horizontal slide show designed ...

Using the innerHTML property to place an Img tag within a div element

I'm facing an issue with including multiple tags within a div using innerHTML. To better illustrate my problem, here's an example: var y = "jack.jpg"; var x = "Jack"; var f = "Hello world!"; document.getElementById("maindDiv").innerHTML += "< ...

Using Ajax to fetch project data from an API

Currently immersed in a personal coding project, I'm struggling to troubleshoot my code. Essentially, I need to retrieve data from an API and display it on my HTML page. The data type is "jsonp" due to CORS errors that required this workaround for de ...

Encountered a Webpack issue when trying to load the primeng.min

I recently initiated a fresh project using yo aspnetcore-spa. My goal is to integrate the PrimeNG component library. Upon installing font-awesome and primeng: npm install font-awesome primeng --save I included CSS in the webpack vendor list: vendor: [ ...

Round corners, images in the background, gradients in the background, and compatibility with Internet Explorer versions 8 and

I've encountered an issue where my div with border radius, background gradient, and background image are working fine in FireFox but not displaying correctly in IE8 or IE10. In IE8, the gradient and background image work properly, but as soon as I app ...