A dynamic 3-column design featuring a top header, fixed footer, and columns that stretch to full height

Struggling to design a layout with specific features:

  • 3 fluid columns
  • Columns that stretch to full height
  • A header
  • Sticky footer

Came across a related query on stackoverflow: CSS layout with header, footer and multiple 100% min-height content columns

The solution provided in the link involved using a table-based layout. However, I'm keen on avoiding tables to easily hide outer columns on smaller screens.

Shared the code created so far here:

The demo shows near success but the ideal layout changes aren't consistent upon resizing.

Currently tackling these resizing bugs:

  1. Transitioning from a tall window to a short one prompts an unnecessary scrollbar.
  2. Moving from a wide window to a narrow one causes middle column content to disappear under the footer.

Experimented with

$(window).height()

in place of

$(document).height()

but encountered new issues as a result.

Any assistance would be greatly valued!

Answer №1

If you're looking to tackle this issue, there are two potential solutions:

One option is to utilize the re-size jQuery function to re-run certain actions when the window is resized.

$(window).resize(function(){
     ////Insert your code here again
})

Alternatively, you could employ CSS properties to create a fixed-positioned DIV at the bottom of the page.

position:fixed; bottom:0; left:0; right:0; height:100px;

Answer №2

Here is a suggestion for you to try:

HTML Code:

<div class="container">
    <header>
        The header
    </header>
    <div class="box green">
        Column 1
    </div>
    <div class="box blue">
        Column 2
    </div>
    <div class="box yellow">
        Column 3
    </div>
    <footer>
        Sticky footer
    </footer>
</div>

CSS Styles:

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

.container {
    height: 100%;
}

header {
    background-color: orange;
}

.green {
    background-color: green;
}

.blue {
    background-color: blue;
}

.yellow {
    background-color: yellow;
}

.box {
    width: calc(100%/3);
    min-height: 100%;
    display: inline-block;
    float: left;
}

footer {
    position: absolute;
    bottom: 0;
}

Check out the live demo on JsFiddle.

Answer №3

After some investigation, I finally came to a solution. It turned out that clearing all the forced column heights before recalculating them upon window resizing was the key.

If you're interested, here's a post detailing my approach:

Appreciate the 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

Having trouble getting the auto complete feature to work in AngularJS with jQuery

I have been attempting for the last 5 hours without any success... Below is the code snippet: Within View: <input type="text" ng-model="foo" auto-complete/>Foo = {{foo}} Inside the controller: myapp.directive('autoComplete', functi ...

Session values do not persist in Window Popups

While the system functions properly in the main window, there is an occasional issue when generating a bill through AJAX. After generating the bill, a window popup automatically opens to display the bill details. However, during this time, the login sess ...

Differences in background size percentage can be observed between Firefox and Webkit browsers

I am encountering an issue with a responsive circular div that has a background gradient. When adjusting the background size, I noticed that they do not match in webkit and Firefox browsers. However, setting the background-size to 100% / auto resolves thi ...

Two vertical divs stacked on top of each other, each expanding to the entire height and width of the browser window

Is there a way to set the width and height of two divs on a webpage to match the dimensions of the browser window, requiring scrolling to view the second div? In addition, how can I ensure that the content within these divs is vertically centered? To ach ...

Posting ajax is causing the URL to exceed its character limit

When I make an ajax call, I encounter an issue with posting a very long textarea value. If the text is short, the post works fine. However, if the textarea contains too many characters, I get an error both during the post and when manually entering the URL ...

I'm looking to design a button with text positioned beneath an icon using either Bootstrap 5 or CSS. How

Is there a way to create buttons like the ones shown in the examples using Bootstrap 5 or custom CSS classes? Examples: [Set of buttons][1] Notice how some of them function as dropdown buttons. I've searched for examples but most of them only show ...

receiving ajax server updates

As a beginner in the world of ajax and wanting to receive constant updates from the server, I have been researching different methods to achieve this. However, I am unsure if my approach will work and would like some feedback on my understanding of the pro ...

"Troubleshooting the lack of background image display in Next.js when using

Can anyone help me figure out why my background image disappears when I add a linear gradient? It shows up fine without the gradient, but as soon as I include it, the image vanishes. <div className="hero" style={{background: "linear-grad ...

My divs seem to overlap in strange, unpredictable ways depending on the zoom level - it's an odd phenomenon that occurs

This situation is causing me frustration... depending on the zoom level of the browser, my boxes do not align properly and it ends up looking messy (in all browsers). Any advice? Could I handle this more effectively with jQuery? HTML </div> <div ...

Is there a way to align the Login and Register buttons next to each other? I specifically want the Register button to redirect to the register.php page using HTML/CSS

Is there a way to align login and register buttons side by side using HTML and CSS? I want the register button to redirect to register.php I attempted to create a register button with the <input> element, but I couldn't get them to display next ...

Fixing the body tag's margin-top property in Yii2

The issue I encountered with my Index was related to the positioning of the contents within the body tag. I was able to resolve it by adding the following code to my site.css: margin-top: 340px; Now, my index is displaying correctly! However, after apply ...

Tips for managing event listeners with JavaScript validation and PHP

Hi everyone, I'm a new student learning Web Programming and focusing on Web Development. I encountered an issue while trying to use JavaScript validation with a form submitted to a PHP file. I attempted to utilize event listeners to check the input fi ...

JavaScript to adjust the size of a div

I have a hidden div in my JSP code that I want to move from one tab to another tab based on the onclick event of the tabs. <div id="addprojectname" style="-moz-border-bottom-colors: none; -moz-border-left-colors: none; -moz-border-right-colors: ...

Unable to trigger the (click) event when adding new data in ANGULAR 4

Whenever I attempt to add the "tr tag", the (click) event is not functioning in Angular 4. Below is my code snippet. $('#time_table_table tbody').append('<tr data-id="1"><td>Sunday<a (click)="assign(1)">Assign</a>< ...

Converting from Jquery to pure JavaScript and the process through which the interpreter searches the DOM for elements

I'm curious about the internals of JavaScript and how it handles certain queries. Specifically, I have a question regarding retrieving images with "flowers" in their src attribute using JQuery. The following JQuery code will do just that: $("img[src ...

What is the best way to assign attributes to all items in an array, excluding the currently selected one?

I need to implement dynamic buttons in my HTML document while a JavaScript class is running and receives a response from the backend. I am using jQuery and vanilla JS, and have included an example below to demonstrate this functionality. The goal is to dis ...

Preventing a webpage from responding to events by utilizing either CSS or jQuery

I apologize if the title is unclear, but I couldn't find the right words to phrase my question. On my website -- -- there is an alert box that appears onLoad. I need to convert it into a modal box so that when it appears, users are unable to use the ...

Switching between React components based on a click event

I want to display a component in another component when it is clicked, similar to this scenario: The DevStatus component consists of two Bootstrap radio buttons. Meanwhile, the IssuesList component includes a Bootstrap list. You can view the code on Code ...

What could be causing my scrollable div to not function properly within a Bootstrap modal?

I am facing a frustrating issue. I have a simple DIV element that I want to make scrollable, containing a table inside it. The process should be straightforward as I have a separate .html file with the code that functions correctly. Here is an excerpt of ...

tips for concealing bootstrap css hover/activate color when scrolling beyond the top

Looking for help with my Bootstrap HTML code: <nav> <ul> <li><a>1</a></li> <li class="active"><a href="#">2</a></li> <li><a>3</a></li> & ...