Completely shrink the middle row first when resizing the browser before shrinking the other rows

Utilizing a simple three row structure:

<div class="EditorHeaderWrapper">
   <h1>Title</h1>
</div>

<div class="EditorMainRowWrapper">
 // Content of the main row goes here
</div>

<div class="EditorFooterWrapper">
</div>

Is there a way to ensure that when the browser height is reduced, the middle row collapses completely before affecting the footer or header?

.EditorHeaderWrapper{
   position:absolute;
   top:0;
   left:0;
   right:0;   
   height:49px;
   background-image:url('blah');
   border-bottom:1px solid black;   
}

.EditorMainRowWrapper{
   position:absolute;
   top:49px;
   left:0;
   right:0;
   bottom:30px;
   background:#f9f9f4;
   overflow:hidden;
}


.EditorFooterWrapper{
   position:absolute;
   bottom:0;
   left:0;
   right:0;   
   height:30px!important;
   background:#3c3b37;
   border-bottom:1px solid black;   
}

You can view a functional demonstration in this fiddle: http://jsfiddle.net/ZaFp8/3/

The issue arises when implementing the code in a real browser (FF26) within the body element without any additional styles present. In this scenario, the footer becomes cutoff prematurely. Jsfiddle introduces some modifications to rectify this problem.

To address this, you may need to include certain definitions for the body, html, or possibly a wrapper div with specific formatting. But what exactly should be added, and why?

Answer №1

To make your footer div absolutely positioned, ensure to set a min-height of 100% for the body and html elements so they can "stretch" to the full height of the window. You do not necessarily have to use absolute positioning for the other two divs - they will naturally align from top to bottom with relative positioning.

I've made some adjustments to your code here: http://jsfiddle.net/hoppergrass/ZaFp8/10/

HTML:

<div>
<div class="EditorHeaderWrapper">
   <h1>Title</h1>
</div>

<div class="EditorMainRowWrapper">
 // Main row content here
</div>

<div class="EditorFooterWrapper">
</div>
</div>

CSS:

 html {
    height: 100%;
}

.EditorHeaderWrapper{
   position:relative;  
   height:49px;
   background:#3c3b37;
   border-bottom:1px solid black;   
}

.EditorMainRowWrapper{
   position: relative;
   overflow:hidden;
}

h1 {
   margin: 0;
    padding: 0;
}
.EditorFooterWrapper{
   position:absolute;
   bottom:0;
   left:0;
   right:0;   
   height:30px!important;
   background:#3c3b37;
   border-bottom:1px solid black;   
}

body {
    min-height: 100%;
    margin: 0;
    padding: 0;
   background:#f9f9f4;
}

Edit: corrections made

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

An unusual type of data is being stored in a MySQL database through Navicat Premium while using Django

Recently, I've encountered an issue while trying to insert data from an HTML form into my database. Strangely, upon submission, the values for "gender" and "website rating" get replaced with "on" instead of the actual input provided through the websit ...

What is the process for calculating and determining the exact area the div should be released?

I am currently developing a drag-and-drop application using only Javascript. I have successfully implemented the dragging functionality, allowing elements to be moved randomly within the page. However, I now face the challenge of creating a drop zone with ...

What is the process for verifying that a checkbox is unchecked through the use of Ajax and PHP?

I am working with a checkbox element in my form. Here is the code: <input type="checkbox" value="yes" id="checkBox"> This checkbox is part of my form, and I am sending the form data to a PHP file using Ajax: var check = $('#checkBox').v ...

The aspect ratio of an image is being calculated by loading the image twice

I am currently facing the issue where the same image is loading twice for a single preview. The first time the image is loaded for preview purposes in an iframe. The second time, the image metadata such as width and height are fetched with the same path. ...

Using Chrome in Application Mode with Shortcuts Disabled

When trying to utilize Chrome in application mode as a host for an HTML5 application, it becomes evident that there are significant limitations. For instance, pressing CTRL+T launches a new Chrome browser window, allowing the user to input text into the a ...

varying heights in bootstrap columns

My goal with utilizing the grid system of Bootstrap 3 is to achieve the following visual layout: View my envisioned image here. However, when using the normal row and col structure, I end up with a different result: See what I actually get here. Is there ...

Issues with Hovering over Button Contained in Slider

I can't seem to figure this out. It should be a simple fix. I have 5 slider images with black buttons that link to different galleries. I want the button background color to change on hover, but it's only working on one of the sliders. It seems ...

Unable to initialize styles in a newly created Angular CLI project

Just finished setting up a new project with the angular cli. Encountering an issue when trying to link the styles.css file in index.html <link rel="stylesheet" type="text/css" href="styles.css"> Getting the following error in Chrome's dev too ...

Printing from a lengthy React DOM using window.print only generates a single page

My React component is capable of rendering markdown and can span multiple pages. Everything looks great when the component is displayed in the browser - scrolling works perfectly. However, whenever I try to print the page using window.print or ctrl + P, ...

Configuring Node.js and express.js for my personal website to showcase my projects

I am new to node.js and I'm excited to implement it on my personal website as a way to start learning. I have successfully set up the node server, but I am struggling with setting up routing using express.js. All my files are typical static files like ...

How can I create a box-shaped outline using Three.js?

As someone new to threejs, I have been trying to figure out how to render a transparent box around a symbol in my canvas. The box should only display a border and the width of this border should be customizable. Currently, I am using wireframe to create a ...

Utilizing XPath to retrieve text from a hyperlink

I'm currently using Python with Xpath to scrape Reddit, specifically working on extracting links and displaying their titles on the front page. To do this, I'm utilizing the Scrapy framework and conducting tests in the Scrapy shell. I'm stru ...

What is the best way to disable the functions doajax_red and doajax_blue when a radio button is checked?

Is there a way to halt the functions doajax_red and doajax_blue when a radio button is checked? Upon loading the page index.php, clicking the red button will display a loading image. If you check the BLUE radio button and then re-check the RED radio butt ...

Ensure that button positioning lines up properly even if adjacent content causes it to shift

I have developed several products using only HTML & CSS. One challenge I am encountering is that when the content inside the div exceeds a certain length, it causes everything to shift down, resulting in uneven alignment (refer to the 3rd product in the i ...

Steps to customize the appearance of a button within a file input field

When implementing the file input in my code on a Mac, I noticed that the alignment appears off. On all other devices, it looks just fine. However, when I try to apply a style specifically to the 'Choose file' button, the style also gets applied t ...

Shapes and their corresponding encoded representations compiled in a comprehensive catalog

Can anyone provide me with a comprehensive list of HTML escaped codes for displaying various shapes on web pages? I need codes that are universally compatible with all browsers. For instance, I would like to display a square using an escaped code in one ...

Uncertainty surrounds the interaction of computed height and margins with CSS float right

What is the reason behind this HTML code: <html> <head> <style type="text/css"> .left { background-color: yellow; } .right { float: right; background-color: lightgray; width: 150px; } </sty ...

Steps to obtain an Element binding from a Svelte component

Is it possible to retrieve the bounding client rect of an anchor element? I typically mark this using the syntax bind:this={someVariable}. However, when I add this code to a Svelte component, I receive a different object that Svelte uses to represent a c ...

Hover functionality for the border animation is disabled, but the SlideToggle feature is operating smoothly

I am interested in changing the right border color of a DIV when another one is hovered over. I had to use a unique solution to make slideToggle work, so I assume this will require a different approach as well. Below is the detailed code: $(document).rea ...

The scroll functionality does not seem to be functioning as intended on mobile devices when

Hey there, I'm currently working on making my navbar sticky and applying it when the page is scrolled. The code I have works flawlessly on desktop, but unfortunately, it doesn't seem to work on the mobile version. Any suggestions? window.addE ...