A fixed footer anchored to the bottom of the viewport, restricted by a maximum height requirement

Within this demonstration, there is a (rather large) footer that sticks to the bottom of the page. However, when the viewport is short, it ends up covering both the header and body. Is there a solution to ensure the footer remains at least a certain distance from the top using only CSS?

We have attempted utilizing min-height and height on body and #outW, but unfortunately, no changes were observed.

http://jsfiddle.net/2XsNH/1/

(Try moving the bottom of your browser window way up in order to witness the yellow footer overlapping the header)

Answer №1

Apologies if my explanation was lacking, but this is the solution I had in mind:

The issue with my initial approach of using position:fixed is that an element with fixed positioning is taken out of the normal document flow. The linked page demonstrates a clever negative margin technique on the content area to accommodate the header.

Answer №2

My suggestion is to achieve this using only CSS by applying a position: relative and setting the z-index values accordingly. For example, assign a value of 10 to the main content and 9 to the footer.

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

Why do I keep getting an ExpressionChangedAfterItHasBeenChecked error after trying to update a random color in an

Is there a way to assign a random color from an array without causing the error message: "ExpressionChangedAfterItHasBeenChecked"? Even though the color of the chip changes quickly before the message appears, it seems like it's working. How can I reso ...

Rearrange the column order for optimal display on both mobile and desktop views

Looking to implement the designs below using grid layout: I attempted this approach, but it did not achieve the desired outcome. http://jsfiddle.net/tomalex0/3fesK/3/ <div> <div class="col-md-9 col-md-push-3 row-one">1</div> < ...

Creating a collection of HTML elements

Is there a proper method to create an array of HTML elements? I attempted the following: array.push(<tr>); array.push(<input type="text">); array.push(/tr); I'm wondering if there is a correct way to accomplish this task. Any guidance wo ...

What is the best way to apply the background color from the bgColour variable to the component styled with the card class?

I am trying to set the variable bgColour inside an if statement to match the background colour of a div with the class of card. However, my attempts to access it have been unsuccessful. Can someone provide guidance on how to resolve this issue? Additiona ...

The Android app fails to load web pages on the mobile device

Encountering an issue - I can access a website from my app on a web browser without any problems. However, when I install the same app on my smartphone, it fails to function. The cause of this problem eludes me. ...

CSS: Creating a block that stretches the entire width of its parent block

I've been facing the same issue multiple times. Whenever I use the float property to display one block, the next block ends up overlapping with the first one. For example: Consider the following block of code: .row_item{ width: 30%; display: block; ...

Adjusting the Pace of a CSS Marquee

My CSS marquee effect is working perfectly, but I am having trouble with the speed. The issue arises when the text length varies - shorter text takes longer to scroll while longer text scrolls quickly. This inconsistency is due to the animation duration an ...

Pass the form data to a Bootstrap modal upon submission of the form

I'm attempting to retrieve form data and convert it to JSON to display in a modal dialog that opens on the Submit button click! This is my progress so far: HTML <form class="form-horizontal" id="configuration-form"> --irrelevant-- <button ...

Ensure that the header remains fixed to the top of the page

How can I keep my header at the top of the page instead of in the middle? `header { position: sticky; top: 0; } <!--body { display: flex; justify-content: center; align-items: center; } h1 {font-family: sans-serif;} h1 {text-align: centre; ...

Pointer-events property in pseudo elements not functioning as expected in Firefox browser

I have a horizontal menu that includes mid-dots (inserted using the ::after pseudo element) to separate the menu items. I want to prevent these mid-dots from being clickable. This works fine in Safari, but in Firefox (v.47), the pointer-events: none prope ...

Is there a way to specifically modify the color of the last digits in a number?

Seeking guidance on changing the color of the last digits of a number if it ends in a zero or more. For instance, transform 0.50 to 0.50, 10.00 to 10.00, 10,000.00 to 10,000.00, 100,050.00 to 100,050.00, and the like. Any assistance in achieving this would ...

Looking to create a subtle border with rounded edges

https://i.sstatic.net/oFS4t.png I'm currently working on creating a smooth, fading green line using an array of points in my code. for(var i = this.trail.length - 1; i > -1 + 1; i--) { var time = this.trail[i][0]; var pos = this.trail[i][ ...

Solving the Issue of Overflow Content Scroll on iOS/iPad 2

I'm facing an issue where I am unable to get the mobile Safari browser to scroll within an iframe on iOS, instead of extending the document to display the entire content. To provide some context, my document structure looks like this — When attemp ...

Guidelines for simultaneously modifying two dropdown select options

Is it possible to have one dropdown automatically change its value based on the selection made in another dropdown? For instance, if 'Value 1' is chosen from 'dropdown 1', can we set 'dropdown 2' to automatically display the ...

Ensure that all panels are set to the same width as the widest panel

Is there a way to make all the panels in my jQuery tabs have the same width as the widest panel? I know that heightStyle:"auto" works for adjusting the height, but is there a similar option like widthStyle:"auto"? I want to show you the current look compa ...

Arranging unrelated divs in alignment

http://codepen.io/anon/pen/Gxbfu <-- Here is the specific portion of the website that needs alignment. My goal is to have Onyx Design perfectly aligned with the right side of the navbar, or to have the navbar extend up to the end of "Onyx Design". The ...

React app (storybook) experiencing loading issues with @font-face

I am struggling to load custom fonts from a local directory. Can someone provide assistance? Below is the code I am currently using: @font-face { font-family: 'My Custom Font'; src: url('./fonts/MyCustomFont.eot'); src: url(&apo ...

Tips for effectively utilizing the page-break property within CSS

I am faced with an issue on my HTML page where multiple angular material cards are being displayed: ... <mat-card class="mat-card-98"> <mat-card-header> <mat-card-title>THIS IS MY TITLE</mat-card-title> < ...

Enhancing the appearance of your website by incorporating external stylesheets and utilizing multiple class names through

Is it possible to use external CSS frameworks like Bootstrap, Semantic UI, or Foundation and still generate base64 class names? This could be achieved if there was a way to apply multiple class names. Currently, you can only assign one class name like thi ...

Unable to access the suggestion list within the modal

I incorporate the PrimeNG AutoComplete feature within a PrimeNG Dialog, displaying a list of elements below the AutoComplete in the dialog. My objectives are: To set the max-height of the modal dialog to 300, and have a visible scrollbar if the total ...