Fixed footer positioned at the bottom of the page regardless of the amount of content present

I'm facing an issue where the footer is not sticking to the bottom of the page as intended. When there is less content, it should be displayed without any scroll, and if there is more content, the footer should appear at the end. Here is the code I am currently using:

<div id='wrapper'>
        <div id="top_bar">
        </div>
        <div id="top_add">
            <div if="left_logo">LOGO</div>
            <div id="top_add">ADD</div>
        </div>
        <div id="content" style="height:auto;width:100%;">
                    <div style="font-size:25px;width:90%;float:left;height:auto;">ABCD
                    </div>
                    <div style="width:10%;height:auto;float:right;">ADV.
                    </div>
        </div>
</div>
<div id="foot">
        <a href="#">Contact Us</a>
</div>

CSS:

html, body {
    height:100%;
    width:100%;
    margin: 0;
    padding: 0;
}
#wrapper {
    height:100%;
    width:100%;
    min-width:1300px;
    min-height:100%;
}
#top_bar {
    width:100%;
    height:45px;
    min-width:1200px;
}
#top_add {
    margin-left:15px;
    height:14%;
    width:100%;
    min-width:1200px;
    min-height:130px;
}
#left_logo {
    width:215px;
    height:100%;
    float:left;
    min-width:200px;
    padding-left:20px;
}
#right_add {
    width:980px;
    height:100%;
    float:left;
    background-color:#E8E8E8;
    min-width:750px;
}
#foot {
    background-color:#333333;
    width:100%;
    height:250px;
}

I need some guidance on what may be causing this issue. Currently, when the content size is small, the max-height property takes up the entire page, leaving it empty, and only displays the footer after scrolling. How can I fix this problem?

Answer №1

If you want to stick the footer to the right, you need to use CSS positioning to set it fixed on the page.

For the bottom div, add the following CSS:

#foot{background-color:#333333;position:fixed;bottom:0px;width:100%;}

Check out the live demo here http://jsfiddle.net/Zsg8G/

Thank you...

EDITED: Hello, I have found the issues in your code. Please try this updated version:

<div id='wrapper'>
        <div id="top_bar"></div>
        <div id="top_add">
            <div if="left_logo">LOGO</div>
            <div id="top_add">ADD</div>
        </div>
        <div id="content" style="">
            <div>ABCD<br/><br/> (content continues) </div>
            <div style="width:10%;height:auto;float:right;">ADV.</div>
        </div>
</div>
<div id="push">&nbsp;</div>
<div id="foot">
        <a href="#">Contact Us</a>
</div>

html,body{height:100%;}
#wrapper
{
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -100px; /* Negative indent footer by its height */
}
#push,#footer{height:100px;}

In the code above, make sure to remove the float: left...

Live demo with more content: http://jsfiddle.net/SCr7b/1/ and with less content: http://jsfiddle.net/HYf7q/

Thank you.

Answer №2

Take a look at the solution provided by Chris Braco in this link:

To prevent overflow under the footer, make sure there is padding below your body content and apply position: absolute; to the footer.

You can see the code with a functional footer here: http://codepen.io/anon/pen/IbmiC

If you encounter any problems, feel free to reach out for assistance.

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

Choose a random cell in Jquery every second

I am searching for a method to choose one div out of sixteen and change its CSS backgrounds. This selection needs to occur every second, so a new div is selected from the group each second. I am struggling with implementing the "every second" functionalit ...

Utilizing Reactstrap to design a customized vertical login page and NavBar with a unique background and text color scheme

I am currently working on creating a login page for accessing the main site that features a NavBar. I am utilizing ReactStrap, but I am facing challenges in making the NavBar vertical instead of horizontal, as well as customizing the background, text color ...

Change justify-content-between to something else

After successfully fixing the issue with aligning the navbar brand in the middle of my navigation bar, I am now facing a new challenge. I want to add a button right before the right navigation toggle, but all my attempts have been unsuccessful so far. I&ap ...

Adjust the class of the iframe element when clicked

I am attempting to change the class of an iframe (soundcloud embedded track) when it is clicked, in order to apply different properties. However, my code doesn't seem to be working as expected. Here is what I have: Here is a snippet from my index.htm ...

Displaying the total count of slides available on the webpage

Check out the custom slider I created on this codepen page: http://codepen.io/anon/pen/NqQpjG I have added an additional feature that tracks the total number of slides that have been moved. For instance, if there are a total of 8 slides, the initial va ...

What is the best way to choose all the checkboxes in a checkbox list, such as a ToDo List?

I am currently working on developing a to-do list where each item includes a checkbox. My goal is to be able to select these checkboxes individually by clicking on them. Furthermore, I would like the checkboxes to toggle between being checked and unchecked ...

:after functionality not operating properly in Internet Explorer

The titles on this page have arrows displayed before them using a special styling. However, there seems to be an issue with how it displays on Internet Explorer. // edit : I made a mistake, my styling is actually on paragraph tags 'p'. Maybe tha ...

Unable to change the variable for the quiz

Currently, I am in the process of developing a quiz app and I am facing an issue with my correct variable not updating. Whenever I trigger the function correctTest() by clicking on the radio button that corresponds to the correct answer, it does get execut ...

Using a ternary condition within the ngClick directive

Trying to implement different functionalities based on the type of device. The setting tab is clickable, and in the desktop version, clicking should redirect to a default URL. However, on mobile devices, clicking the same link should open a modal window. ...

Firebug displays CSS rule as blank

When I look at the styles in Firebug, I notice that the rule below has no content: .holest-carousel-top-item { box-shadow: 1px 1px 1px #FFF,-1px -1px 1px #9ACC67;border-radius: 85px; } Additionally, this rule is not displaying correctly in Firefox. ...

Nodejs Websocket integration with the Firefox browser

Currently, I am utilizing Aurora 17 along with Chrome 22 and Firefox 16 in order to develop a basic chat application. My server-side technology is Node 0.8.9. The issue I am experiencing pertains specifically to Firefox, as it fails to establish a connect ...

unexpected behavior when using jquery click function

I am currently working on a unique custom radio element that showcases images instead of the standard radio buttons. The basic HTML structure looks like this: <div id="wrap"> <p></p> <input type="radio" data-check='class-c ...

What is the process for linking my HTML page to my CSS stylesheet?

This is similar to what I have in the content of my HTML page. <link rel="stylesheet" type="text/css" href="/untitled2.css"> I thought this was right, but it doesn't seem to be functioning. Any ideas on what might be wrong? ...

The words run out before the paper does. Keep reading for more details

While updating the CSS on my blog, I ran into an issue where the text in my posts is not extending all the way to the end. To see what I'm experiencing, check out this image- I really need the text to align properly and reach the full width of the p ...

Create a circular rolling image effect using CSS3 and jQuery when the page is loaded

My div box features a rounded image that I want to roll like a ball on the floor after the page loads. After rolling, I want to position the image perfectly at the center of the box. css: #box{width:900px;height:150px;position:relative;background:red;ove ...

What are some methods for decelerating typewriter text animation?

I'm currently updating my portfolio and have incorporated a typewriter effect into the second line of text. However, I'm finding that the speed of the effect is a bit too fast for my liking. I've attempted to adjust the animation seconds, de ...

How can I ensure that a bigger sprite image fits inside a smaller div?

I have a unique situation where I am working with a large image sprite that is 1030px by 510px and contains two smaller images, each being 515px by 515px. My goal is to extract the two small images from the sprite and set them as backgrounds for two <im ...

Leveraging a global variable value within an AJAX JSON POST request

I want to send a JSON post request to my Elasticsearch instance using AJAX. Is it possible to include a global variable's value in the 'data' section of the request? Could it look something like this? $(document).ready(function() { $(&ap ...

Enable the input field once the checkbox has been marked

Here is a checkbox example: <div class="form-group"> <input type="checkbox" id="examination" class="form-control" name="exam" placeholder="Enter Title"> <label>Enable Exam</label> </div> Additionally, I have a disabled inpu ...

Maintain consistent spacing after receiving a value

I have a content editable span where you can write whatever you want. For example: Hello, My name is Ari. However, when I try to retrieve the text and alert it using my program, it displays without any line breaks or spacing like this: "Hello,My name is ...