Issues with footers in IE 10/11 and Edge when using Grid layout

In the latest versions of Chrome, Firefox, Opera, IE 10/11 and Edge, the Grid layout below works perfectly fine. The only issue is with the Microsoft browsers where the footer fails to start scrolling when the content exceeds the screen size, leaving it fixed in the middle of the page. This results in longer content overwriting the footer.

After numerous days of research, I have yet to find a suitable solution. While many suggestions involve moving the footer outside of the wrapper, I am seeking a method that can be integrated into the existing markup of the page.

I suspect there may be a height-related problem causing this issue, but after exhausting my own ideas, I have decided to seek help from this forum. Perhaps one of you can provide a fresh perspective on this matter.

Any guidance on how to tackle this predicament would be greatly appreciated.

Answer №1

When using Flexbox and CSS Grid, an issue arises with the min-height property in Internet Explorer and CSS Grid.

To address this problem, ensure that the parent of the wrapper, which is usually the body, is set as a flex column container to accommodate the min-height requirement for expanding content and aligning the footer correctly in IE.

Note: It is also necessary to remove the height: 100% on html/body, as well as the height: 100vh on the wrapper.

Check out the stack snippet below:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {}

body {
  display: flex;
  flex-direction: column;
}


/* main grid layout start */

.wrapper {
  display: grid;
  display: -ms-grid;
  grid-template-columns: 10% 80% 10%;
  grid-template-rows: 45px 50px 1fr 50px;
  grid-template-areas: "header header header" "navigation navigation navigation" "column-left column-center column-right" "footer footer footer";
  min-height: 100vh;
  -ms-grid-columns: 10% 80% 10%;
  -ms-grid-rows: 45px 50px 1fr 50px;
}

.item-header {
  background-color: pink;
  grid-area: header;
  -ms-grid-row: 1;
  -ms-grid-column: 1;
  -ms-grid-column-span: 3;
}

.item-nav {
  background-color: silver;
  grid-area: navigation;
  -ms-grid-row: 2;
  -ms-grid-column: 1;
  -ms-grid-column-span: 3;
}

.item-leftcol {
  background-color: skyblue;
  grid-area: column-left;
  -ms-grid-row: 3;
  -ms-grid-column: 1;
}

.item-centercol {
  grid-area: column-center;
  -ms-grid-row: 3;
  -ms-grid-column: 2;
}

...
<!-- Code truncated for brevity -->
...

.fc3 {
  background-color: red;
  text-align: right;
  flex-grow: 1;
  flex-basis: 0;
  -ms-flex-positive: 1; // flex-grow
  -ms-flex-preferred-size: 0; // flex-basis
}
<div class="wrapper">
  <div class="item-header">header</div>
  <div class="item-nav">nav</div>
  <div class="item-leftcol">left</div>
  <div class="item-centercol">center</div>
  <div class="item-rightcol">right</div>
  <div class="item-footer">
    <div class="fc1">footer</div>
    <!-- just added this -->
    <div class="fc2">footer</div>
    <!-- just added this -->
    <div class="fc3">footer</div>
    <!-- just added this -->
  </div>
</div>


A workaround for this issue is to utilize display: grid with a similar approach. Check out the updated stack snippet below:


...
<!-- Same CSS code as above but adjusted for Grid Layout -->
...
<div class="wrapper">
  <div class="item-header">header</div>
  <div class="item-nav">nav</div>
  <div class="item-leftcol">left</div>
  <div class="item-centercol">center</div>
  <div class="item-rightcol">right</div>
  <div class="item-footer">
    <div class="fc1">footer</div>
    <!-- just added this -->
    <div class="fc2">footer</div>
    <!-- just added this -->
    <div class="fc3">footer</div>
    <!-- just added this -->
  </div>
</div>

Answer №2

After much troubleshooting, I finally found the solution to my problem. The main issue was the use of height:100vh; in the .wrapper CSS class. I discovered that IE10/IE11 and Edge each handle this property differently. While it caused no issues in FF, Chrome, or Opera (I can't confirm for Safari), I had to adjust my code based on browser and page height.

The Issue with IE10/IE11:

In IE10/IE11, the problem is two-fold:

If height:100vh; is set in .wrapper, pages shorter than the viewport display correctly, with the footer at the bottom. However, removing this property causes the footer to hang mid-page on such pages.

Conversely, for pages taller than the viewport, the header remains fixed at the bottom upon loading but then sticks as the user scrolls. Removing height:100vh; from .wrapper allows the footer to be pushed down as intended.

Therefore, smaller pages benefit from height:100vh;, while larger ones do not need it.

Solutions for IE10/IE11:

Solution 1: Apply height:100vh; to pages shorter than the viewport height using media queries:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .wrapper {
        height: 100vh;
    }
}

This method works but might not be ideal.

Solution 2: Use JavaScript to determine when to include height:100vh; dynamically.

The following JavaScript addresses the IE10/IE11 situation:

function setHeightIETenEleven()
{
    var isIE10 = false;
    var isIE11 = false;

    /* Check for IE10 */
    /*@cc_on
        if (/^10/.test(@_jscript_version)) {
            isIE10 = true;
        }
    @*/

    /* If not IE10, check for IE11 */
    if(!isIE10) {
        var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
    }

    if(isIE10 || isIE11) {
        var actualHeight = document.body.scrollHeight;
        var clientHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
        if(actualHeight == clientHeight)
            insertCss(".wrapper {height: 100vh;}");
    }
}

function insertCss( code ) {
    var style = document.createElement('style');
    style.type = 'text/css';

    if (style.styleSheet) { // For IE
        style.styleSheet.cssText = code;
    } else { // For other browsers
        style.innerHTML = code;
    }

    document.getElementsByTagName("head")[0].appendChild( style );
}

window.onload = setHeightIETenEleven;

I must credit the insertCss() function source: How do you add CSS with Javascript?

Given its dynamic nature, this approach is preferred.

The Edge Situation:

Edge initially presented similar issues to IE10/IE11, but removing the height property resolved them immediately, regardless of page height. To ensure compatibility with Edge, use the following:

@supports (-ms-ime-align: auto) {
    .wrapper {
        height: unset;
    }
}

For all other browsers, utilize:

@supports not (-ms-high-contrast: none) {
    .wrapper {
        height: 100vh;
    }
}

More complex than expected, but it gets the job done...

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 border class in Bootstrap 4 seems to be malfunctioning when it comes to the top

I'm struggling to add a border to a div using Bootstrap 4. When I try using only the border property, it looks strange, and when I use other properties, no border appears. Here is the code snippet: I even tried with the beta 2 version. If there is s ...

What are the best methods for creating a responsive div container?

Hello, I am having trouble with the responsiveness of my div. I want these two images to stack on top of each other when the window is resized. I have attached a screenshot to demonstrate exactly what I am trying to achieve. I can't seem to figure out ...

Tips on Selecting a Typed Value

When clicking on 'no_results_text' and it's not available in the list, I want to show the searched value from the alert. I have included an onclick method for 'no_results_text', so that the typed value is displayed in the alert. h ...

Addressing duplicate CSS issues in Firebug?

CSS: .list-a .desc-fix { width: 180px; margin: 0px auto; position: relative; } .list-a .desc { background: url("../images/trans_black.png") repeat; display: block; font-family: arial; font-size: small; height: 18px; mar ...

Adjust Font Size inside Circular Shape using CSS/jQuery

I have been searching for different libraries that can resize text based on the size of a container. However, my container is circular and I am facing difficulty in preventing the text from overflowing beyond the border. Below you will find a Fiddle conta ...

Connect a responsive div to a main div

I'm relatively new to the world of Javascript, CSS, and HTML. Currently, I'm attempting to anchor a div to the center and bottom of its parent div. The parent div contains a responsive background image and my fa fa-arrow icon is correctly positi ...

Disappear scrollbar when overlay is activated

How can I hide the scroll bar when an overlay is displayed on my page? .overlay{ display: none; opacity:0.8; background-color:#ccc; position:fixed; width:100%; height:10 ...

Creating a dynamic webpage with flexible design and interconnected containers using the Bootstrap framework

Creating a responsive layout with nested divs using Bootstrap Check out my HTML code below: <div class="container-fluid" style="height: 350px;"> <div class="row-fluid clearfix" style="height: 100%"> <div class="col-md-9 column" ...

Difficulty arranging these elements in CSS

I'm attempting to achieve the following: (The black box represents a signup/login section, the blue is a navigation bar, and the red is a header area with some text content) I'm trying to reach this outcome with the following CSS: @import url(/ ...

Tips for adjusting image size to take up only half of the screen in NextJS

Struggling to resize an image to fit only 50% of the screen in NextJS? The Image component provided by NextJS comes with its own inline styling, making it tricky to customize. Currently, I attempt to style the image by wrapping the Image component in a spa ...

Maintain the selected list item after filtering in AngularJS

I am facing an issue with highlighting selected items in a list. I have three first names: Roy, Sam, David displayed in a ul as list items. Initially, I can toggle each li on click just fine. However, after performing a search and returning to the list, th ...

What is the best way to select an HTML tag element using the :v-deep() selector?

When I utilize the following: ::v-deep img { ... } it functions but triggers a deprecation warning: [@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead. How can I achieve the same effect using ...

In the Firebug console, Ajax posts are highlighted in a vibrant red color

Upon executing the code provided, the Firebug was enabled. While submitting the form, in the console, the message "post to login_submit.php" appeared in red. However, there was no response received as well. <!DOCTYPE html> <html> ...

When working with Vuejs, if you try to use "axios" in a .js file, you may encounter an error

I am currently working with VueJS and attempting to send a GET request to my API. I am using axios, but encountering an issue when trying to import it. If I use require for the import, I receive this error: Uncaught ReferenceError: require is not defined. ...

Ways to expand the div to fit the width of the text after it has been wrapped

I need a continuous underline to stretch across the remaining width after the text wraps in a table cell. Here is the desired effect: https://i.sstatic.net/XNNyj.png If the text wrapping changes, the underline width should adjust accordingly. This is w ...

Potential image positioned to the left of a detailed description

A Meteor client template helper contains an array of objects {image: url, label: description}. The URL can either point to a valid image file in the public directory or be the string 'non'. The description can range from a few words to several ...

PHP and mysqli combine to create a versatile image slider with changing images

I am looking to implement an image slider that can be updated by the admin using php and mysqli. The admin should have the ability to easily add or remove images as needed. ...

HTML links have been disabled

I have been making updates to the charity website I manage, heroinitiative.org. You can view the revamp progress here: (please note that this is not live code, it is simply for my boss to see the progress and does not need to be kept secret, hence why I a ...

Is there a way to separate a string similar to the way bbcode does?

$answer = "This is simply a placeholder text example. WOW! Check out this link [link=http://www.yahoo.com] yahoo yahoo[/link]"; Hey there, I am developing a discussion platform, and my goal is to allow users to use specific tags like [link=*link*]*text*[/ ...

Ways to display an image overlay on hover using sprite sheets

Is there a way to make a line appear, around 10px in size, when hovering over an image at the bottom of that image? I came across this effect on MTV's website within their "You would also like these" section below each post. They utilized css-backgro ...