What is the best way to adjust the height of a Div to be 100%?

I've been struggling to make the .footer and the div .content have a height of 100%. While I know how to get the footer to stick at the bottom, I can't seem to make the content div reach the bottom of the page. Increasing the min-height on the content div isn't solving the issue.

You can check out my site here

This is what I'm aiming for but finding it difficult to align the center page and footer to the bottom of the page.

See the image here

CODE

<body>
    <div class="header">
    </div>  
    <div class="content">
        <div class="page-content">
            <div class="column_4"></div>
            <div class="column_5"></div>
            <div class="column_6"></div>
            <div class="column_7"></div>
        </div>  
    </div>
    <div class="footer">
    </div>      
    <div style="display:none">
    </div>
</body>

body {
    font-family: 'Open Sans', Arial, Helvetica, sans-serif;
    margin:0;
    font-size: 15px;
    font-weight: 400;
    line-height: 157%;
    color: #666666;
    padding:0;
}
.content {
    min-height: 0;
.header {
    min-height:300px;
    background-color:#000000;
}
.footer {
    min-height:300px;
    background-color:#000000;
}
    background-color:#9E959E;
}

After implementing your suggestions, this is what I currently have:

html,body {
    height:100%;
}
body {
    font-family: 'Open Sans', Arial, Helvetica, sans-serif;
    margin:0;
    font-size: 15px;
    font-weight: 400;
    line-height: 157%;
    color: #666666;
    padding:0;

}
.content {
    min-height: 0;
    background-color: #9E959E;
    height: calc(100% - 50px); /* add this */ 
}

.footer {
    min-height: 25px;
    margin-left: auto;
    margin-right: auto;
    background-color:#000000;
    clear: both;
    position:fixed;
    right:0px;
    left:0px;
    bottom:0px;
}

.header {
    min-height:300px;
    background-color:#000000;
}
@media only screen and (min-width : 768px) {
    .header {
        min-height: 25px;
    }
}
@media only screen and (min-width : 992px) {
    .header {
        min-height: 25px;
    }
}



<body>
    <div class="header">
    </div>  
    <div class="content">
        <div class="page-content">
            <div class="column_4"></div>
            <div class="column_5"></div>
            <div class="column_6"></div>
            <div class="column_7"></div>
        </div>  
    </div>
    <div class="footer">
    </div>      
    <div style="display:none">
    </div>
</body>

Answer №1

Replace

.footer {
min-height: 25px;
margin-left: auto;
margin-right: auto;
background-color:#000000;
clear: both;
}

with the following code:

.footer {
min-height: 25px;
margin-left: auto;
margin-right: auto;
background-color:#000000;
clear: both;
position:fixed;
right:0px;
left:0px;
bottom:0px;
}

Using this will position the footer next to the content, more information can be found in this 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

preventing a button from triggering the same event repeatedly

Currently, I am using a script that adds a new row after the tr where my button is located. Unfortunately, I do not want the same button to generate more than one tr. Here is the script in question: <script> $(function() { var done; $(' ...

Encountering an error in a Laravel application when attempting to return JSON data using

After submitting my page, I am trying to display any validation errors underneath the appropriate form field if there are any. Currently, I am encountering an error in my console. If you could take a look at the code and suggest any changes to improve it, ...

Prevent manual scrolling with CSS

I've incorporated CSS smooth scrolling into my project, which is activated by clicking a specific div element. My current goal is to prevent manual scrolling on the page so that users can only navigate by clicking the designated div and not by conven ...

What is the best way to eliminate an unassigned margin from my layout?

The content of my css file is as follows: .menu { background-color: black; color: white; height: 100px; opacity: 0.5; } html { background-image: url('image.jpg'); background-size:cover; } Despite the lack of text ...

What is the best way to apply overlays to customize a specific part of a single character while also accommodating dynamic width adjustments?

Query Is it feasible to style a specific portion of a single character? Interpretation You cannot apply CSS attributes to parts of characters. However, if you wish to style only a particular section of a character, there is currently no standardized met ...

Column Flow in CSS Grid: Maximizing Auto-Fit - How to Optimize Row Layouts?

Having some trouble understanding how auto-fill and fit work in grid layouts. I am familiar with basic CSS, but new to working with grid layouts. I have a set of checkbox items with labels that I want to display in columns depending on screen size, with c ...

What could be the reason behind the ajax call not getting triggered?

Upon page load, the first alert is displaying correctly. However, the alert inside the ajax call is not triggering. It appears that the ajax call itself is not functioning as intended - it is supposed to invoke a method in the controller, but no longer s ...

Ways to enclose this text with a white border and apply a box-shadow

How can I modify text similar to this image and what is the process involved? ...

Dynamic Bootstrap Table with Fixed Header

I am customizing a Bootstrap table by adding CSS for a sticky header. My code snippet includes the following: .table-sticky th { background: #fff; position: sticky; top: -1px; z-index: 990; } <div class ...

Adjust PATH for the jQuery AJAX call

Within my perspective, I have a form along with an AJAX event triggering upon the form submission: var info = { message1: $("#msg1").val(), message2: $("#msg1").val(), message3: $("#msg1").val(), }; ...

What could be causing the video not to display in landscape mode on the iPad Pro?

I'm having an issue with a standard HTML5 <video> on my website. The videos are working fine on most devices, however there is a problem specifically with the iPad Pro in landscape orientation. It seems to work properly in portrait orientation ...

Trigger a jQuery event when a key is pressed in an input field located in the last row of the table body, even as more rows are dynamically being

Looking for some help with dynamically adding rows to a table. Here's the markup: <table id="myTable"> <thead> <tr> <th>FirstName</th> <th>LastName</th> </tr> </thead> &l ...

Coordinated Universal Time on the Website

I am currently developing a website that will be exclusively accessible through the intranet, but it targets users across Australia. Recently, I have been instructed to explore the idea of incorporating UTC time on the site. I am contemplating how I can i ...

Issues with fonts in Google Chrome Version 32.0.1700.76 m

After recently updating my Google Chrome browser, I noticed that some of the fonts are not displaying correctly. Interestingly, they appear fine on other browsers, but the issue only seems to occur in Chrome v32.0.17...76 m. The fonts I used were "Open Sa ...

How can a regular number be used to create an instance of BigInteger in jsbn.js?

I attempted both methods: const num1 = new BigNumber(5); And const num2 = new BigNumber(7, 10); However, I encountered the following error: Error: 'undefined' is not an object (evaluating 'num2.nextBytes') bnpFromNumberjsbn2.js:126 ...

Struggling with a filtering and sorting problem in my code, looking for some assistance

I'm encountering an issue with an isotope filter menu. The goal is for it to load data based on a timestamp and allow filtering. However, there seems to be a conflict between my sortBy script and the filter script. Below is the code in question: Sor ...

A mysterious JavaScript snippet that automatically scrolls down when the webpage is loaded

Recently, I encountered an issue with a mysterious JavaScript script that automatically scrolls down when entering the page (I suspect it's JavaScript). I've tried to investigate using Firebug, examining the code, deleting scripts, and even remov ...

Determine the specific table entry that was clicked on

Currently, I am working on developing a dynamic table that includes a button in one of its columns, which triggers a bootstrap modal. I'm a bit unsure on how to determine which button was clicked and how to populate the table accordingly. Admittedly, ...

Limiting zero is ineffective when it comes to pop-up issues

Hey there, I'm looking to prevent users from inputting zero and dot in a specific field, which is currently working fine. However, when the field is within a pop-up, the code below doesn't seem to work. <script> $('#name').keyp ...

Tips on adjusting a JavaScript animation function

I'm currently working on adjusting the animation function within the "popup" class that controls the gallery section of a website. When the page loads, an image and background start expanding from zero scale in the center to 100 VIEWPORT HEIGHT (VH) a ...