Creating a simple vertical layout with a fixed header and footer using basic HTML and CSS, allowing for easy stretching and customization

Looking for advice on creating a vertical layout with a static height header and footer, while allowing the center to occupy all available space and adjust to the window height.


header
------

center

------

footer

Any suggestions would be greatly appreciated!

Note: Absolute positioning is not an option for this project.

Answer №1

It seems that I have found exactly what you are searching for
Check out this jsFiddle code

To adjust the spacing of the middle <div>, utilize margins and set margin-top and margin-bottom to -50px, based on the height of your header and footer.

If you prefer a different approach, consider using this slightly unconventional method for adding content to the center section of your webpage. View the alternative jsFiddle example here

Answer №2

While jacktheripper's solution may work, I would not recommend it due to potential cross-browser compatibility issues. You might want to check out Ryan Fait's "Sticky Footer" for a more reliable option. You can find it here. Another similar solution is the 'CSS Sticky Footer', which can be found here, although I have not personally used it. Both should function similarly without requiring a 'push div'. Make sure to review the 'Known Issues' section on this page before implementing.

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

The arrangement of bootstrap elements varies based on whether they are displayed in one or two columns

I'm facing a challenge with my webpage layout that displays two columns of cards. When the screen width is smaller than md size, I want the most important items to be positioned higher on the page. To achieve this, I have arranged the items alphabetic ...

Make the child element's width equal to the parent element's height using only CSS

Is it possible to make the width of a child-div match the parent-div's height using only CSS? Check out this JsFiddle Demo Typically, I would use jQuery like this: $("#child-div").width($("#child-div").parent().height()); But I really need to ac ...

Steps to troubleshoot the TypeError: cv.Mat is not a constructor in opencv.js issue

Encountering a problem while trying to use opencv.js for detecting aruco markers from my camera. Each time I attempt to utilize the method let image = new cv.imread('img'); An error keeps popping up: TypeError: cv.Mat is not a constructor ...

Tips for utilizing numerous tables with multiple selection tags

I am struggling with a jQuery issue involving multiple container elements with the class "product-sizes". Each container contains a select option for choosing between inches and centimeters, which triggers the corresponding table display. The problem arise ...

Change the text color of the Vuetify button to customize its appearance

Is there a way to change the default active color for button text in a toolbar using CSS? v-btn(:to="item.path" active-class="v-btn--active toolbar-btn-active") {{item.meta.title}} I attempted to override it with this custom class: .toolbar-btn-active { ...

Exploring the world of title attribute tooltips and iframes

Is there a way to customize the appearance of a title attribute without losing its natural ability to extend beyond the borders of an iframe? ...

List of elements inside an HTML box

In my current HTML project, I am trying to include a box on a webpage that contains a scrollable list of elements. I want the content inside the box to scroll independently without affecting the rest of the page. Is there a way to achieve this? ...

Adjust the CSS of a nested div within the currently selected div upon page load

I am facing an issue with a page that users access by clicking through an ebook. Upon clicking a link, they are directed to a specific product on the page, and the URLs look like example.com/#product1 example.com/#product6 example.com/#product15, etc... ...

What is the best way to automatically close a modal window after pressing the submit button

Having some trouble with my modal window using pure CSS. Can't seem to get it to disappear after clicking the submit button. Any suggestions on how to hide it properly? Here is the code snippet of both the HTML and CSS for reference. Open to all ideas ...

Issues with AngularJS ng-bind-html failing to display list items

I am working with a basic HTML document that looks like this... <ol> <li><strong>Test 1</strong></li> <li><strong>Test 2</strong></li> </ol> ...and I am attempting to connect it to a div ...

The functionality of an AJAX poll is not functioning properly due to issues with the PHP

I am embarking on my first website and project, hoping to see it through to completion. In my room, I have a modest site set up on a Raspberry Pi 2. Users visit this site to cast their votes of 'yes' or 'no'. However, there seems to be ...

How can I ensure perfect center alignment in CSS?

Is there a preferred method for centering elements using CSS? <div style="position: absolute; left: 50%;"> <div style="position: relative; left: -50%"> Centered content </div> </div> or simply <div style=" ...

creating a table with only two td's for formatting

My ultimate goal is to keep my web form code as minimal as possible for easier maintenance. I am currently working on creating a questionnaire and have been using two td elements for this purpose. Here is an example of what the current text structure looks ...

Implementing Bootstrap in Wordpress using functions.php

The code snippet below is stored in my functions.php file within a Child theme directory. <?php function theme_styles() { wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/bootstrap.min.css' ); wp_enqueue_ ...

The CSS overlay effect refuses to shut down

Greetings everyone, I'm new around here so please bear with me. I am encountering an issue wherein the overlay only works in one direction - it appears when the button is clicked, but nothing happens when attempting to close it. I have tried adjustin ...

Developed a basic HTML form using PHP, however encountering issue where email is not being posted and instead opening a blank page

After creating HTML and PHP documents, I encountered an issue where upon submitting the form, I ended up with a blank page and didn't receive the expected email containing the form information. As someone relatively new to this, I would greatly apprec ...

HTML table row content should be aligned to the left side

I am attempting to align the data in the 'Address' column without any margin. I want it to start from the left since it's overflowing. You can find the HTML, CSS, and JS code here Even though I tried using <td align="left">..</td& ...

Problem with the transparency of CSS, div, and asp:Image

I am facing an issue with a div that has its opacity set to 60. Within this div, there is an asp:Image element. It seems like the opacity of the div is also affecting the image inside it. I attempted to create a separate class for the image and adjust th ...

Maintain the original alignment of table cells <td> even when the <tbody> element is set to display:block

I've been working on creating a theme for SMF, but I'm encountering some challenges with the tables. Here's an example of my HTML code: <div id="wrapper"> <table class="table_list"> <tbody class="header"> ...

Encountered a problem while trying to inflate the class named (horizontalListView

I am attempting to implement a horizontal view, but I am encountering this error: android.view.InflateException: Binary XML file line #39: Error inflating class com.devsmart.android.ui.HorizontialListView The following method is where the error occurs: p ...