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

Guide to dynamically refreshing a section of the webpage while fetching data from the database

I'm currently developing a website using PHP & MySQL where some queries return multiple records. Each record has its own dedicated page, allowing users to navigate between them using arrows. So far, everything is working smoothly. However, I've ...

Error in Chrome: Text container's height is not fully extended to 100%

I'm encountering an issue with achieving 100% height on a child container in Google Chrome, although it works perfectly fine on Firefox. Here is the URL: http://linco.com.py/beta/multiplaza/cartelera.php The styling for the main container is as fol ...

Adjust text alignment of SVG elements using CSS

I am facing an issue where I am unable to change the x and y variables of Svg text tags using CSS. This should work as it does with Svg and . However, I am only able to make changes if I directly add the x and y positions in the HTML code. Html: <svg ...

Why is the parameter value becoming null during an Ajax call?

I am passing a parameter from HTML to JSP, but when I try to retrieve the value in JSP, it returns null. Can someone help me figure out what's wrong with my code and provide any suggestions? The value is successfully displayed in an alert using JavaS ...

Exploring the challenges of using WordPress as a headless CMS in conjunction with Next.js, especially when it comes to efficiently rendering post content

Although my post content is displaying properly, I am unable to get the code highlights to work for the examples included in my post. To provide some context, I am utilizing WordPress GraphQL backend and Next.js on the frontend by referencing this tutorial ...

How can we restrict a textbox to only accept alphanumeric characters using solely HTML code?

Imagine a scenario where you have a textbox and your goal is to allow only alphanumeric characters (case insensitive). You've already achieved this using javascript and regex.test(), but now you're wondering if there is a simpler way to implement ...

What is the best way to ensure the width of the div is adjusted to fit the table it contains?

What is the best way to adjust the width of a div containing a potentially wider-than-screen table? Despite setting padding: 10px for the div, the right padding disappears when the table exceeds the screen width. Below is an example code snippet: <div ...

What is the best way to dynamically assign an id to an ajax Actionlink in ASP.NET?

I have a collection of items and each item contains an Ajax.ActionLink. I would like to dynamically set the id for each action link based on the item's id. @Ajax.ActionLink("Join","ajaxview", new{id = tour.TourId}, new { HttpMethod = "GET", Insertion ...

Lock the initial column in an HTML table

Hey there! I've been trying to freeze the first column of my HTML table, and while I managed to do so after a few attempts, I encountered an issue. When I scroll the table horizontally, the columns on the left seem to overlap with the first column, an ...

Automatically adjust multiple images on an HTML webpage

Just starting out with html programming here. Looking to add top margin using a span class, any tips on how to tackle this issue? ...

Navigating through the website has become quite challenging due to the malfunctioning navigation bar. Instead

I recently completed a website and designed an awesome navigation bar in a separate file. However, when I combined them together, the navigation bar disappeared. The background of my "list" div should be filled in and larger, but it's not working as e ...

Which HTML tag should I choose to apply color to text in Twitter Bootstrap?

I'm looking to enhance the appearance of a specific word in my text. For example: This is my text, <span class="red">this</span> should be red. Would using the span tag be the appropriate method for achieving this effect? Or are there ot ...

Upload files via Ajax request is required

I am in the process of trying to upload a binary file to a server while avoiding a full page refresh when the server responds. I must admit, I am not well-versed in this area and I understand if my approach needs some adjustments. This is how I have appro ...

Having trouble with JQuery's $.post function not functioning on your web server?

I'm encountering an issue with my script that uses Ajax to send a request to my PHP file for updating a txt file. Interestingly, the script works perfectly fine on my localhost but fails to work on the webserver. Testing HTML code: <!DOCTYPE html ...

Exploring the wonders of JQuery and the magic of Ajax

Currently, I'm in the process of implementing asynchronous form submission within a jquery dialog by utilizing .ajax(). Although everything is functioning properly, I find that the submission process is taking longer than expected. As a newcomer to jq ...

Positioning Input and Dropdown Elements within a Data Table Using CSS

I am currently working on setting up a data table for an application using Vue.js, and I am facing a challenge in relation to the arrangement of input elements. The specific requirement is that certain columns within the table should contain values that ar ...

There seems to be a hiccup in the JavaScript Console. It could potentially impact the functionality

Hey there, I'm encountering a strange issue in my IE 11 console. A JavaScript Console error has occurred. This may impact functionality. Whenever I try to run a for loop to create a list of elements within a ul tag 4000 times, the process stops at ...

Maximizing cell background color in HTML table with limited width fails to function properly

Having difficulty turning the header cells (th) with background-color applied? It seems like the color bar may be too small, the cell width too large, or the background isn't being affected properly. Is there a way to create a narrow cell with long t ...

Error in Typescript: Draggable function is undefined

I'm currently working with typescript alongside vue and jquery ui. Encountering the error "TypeError: item.$element.draggable is not a function". What am I doing wrong in my code? I have already included jquery-ui, as shown in the following files. M ...

How to omit a specific tag from the get_the_tag_list function in WordPress

When outputting single post tags using a custom template tag, I typically use the following code: <?php echo get_the_tag_list('<p class="text-muted"><i class="fa fa-tags"></i> ',', ','</p>'); ?> ...