IE11 fails to adhere to specified sizes in CSS Grid layout

I've been trying to replicate the display:grid and grid-template-columns functionality on IE11, but I can't seem to get it to work properly like it does in Chrome. What am I missing? Also, when I pasted my code into the snippet, the yellow bar doesn't appear.

.ctn_mapa_hoteles {
  display: grid;
  display: -ms-grid;
  grid-template-columns: 300px 790px auto;
  -ms-grid-columns: 300px 790px auto;
}

.col_ctn_filtros {
  height: 85vh;
  padding: 30px;
  overflow-y: auto;
  background-color: cyan;
}

.col_ctn_hoteles {
  padding-left: 0px;
  padding-right: 0px;
  background-color: #f5f5f5;
}

.col_ctn_mapa {
  background-color: yellow;
}
<div class="ctn_mapa_hoteles">
  <div class="col_ctn_filtros">
  </div>
  <div class="col_ctn_hoteles">
  </div>
  <div class="col_ctn_mapa">
  </div>
</div>

Answer №1

To ensure proper display in IE 11, you must explicitly define the position of each child element within the grid:

.ctn_mapa_hoteles {
  grid-template-columns: 300px 790px auto;
  display: grid;
}

.col_ctn_filtros {
  height: 85vh;
  padding: 30px;
  overflow-y: auto;
  background-color: cyan;
}

.col_ctn_hoteles {
  padding-left: 0px;
  padding-right: 0px;
  background-color: #f5f5f5;
}

.col_ctn_mapa {
  background-color: yellow;
}
/* IE11 fix grid layout */
.ctn_mapa_hoteles {
  display: -ms-grid;
  -ms-grid-columns: 300px 790px 1fr;/* note 1fr instead auto */
}

.col_ctn_filtros {
  -ms-grid-column:1;
}

.col_ctn_hoteles {
  -ms-grid-column:2;
}

.col_ctn_mapa {
  -ms-grid-column:3;
}
<div class="ctn_mapa_hoteles">
  <div class="col_ctn_filtros">12
  </div>
  <div class="col_ctn_hoteles">45
  </div>
  <div class="col_ctn_mapa">78
  </div>
</div>

For a live example that works in IE11, check out this jsbin link: https://jsbin.com/qiwehinuwi/1/edit?html,css,output

If you need to use auto-flow for grid layouts but it's not supported in IE, consider setting up an alternative layout specifically for IE. Here is another question discussing a responsive layout example for IE11: Responsive Layout when using grid

Answer №2

I've encountered the same issue before. Internet Explorer can be tough for developers to work with. While both Grids and Flexbox have their advantages, I personally prefer using Grids. Unfortunately, IE does not support Grids, so it's necessary to implement a Flexbox fallback solution using media queries.

 // Fallback for IE 
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {

// Insert flexbox code here

.yourdivclassname {
  display: inline-flex;

}

}

For other browsers that support Grid (such as Firefox, Chrome, Edge, etc)

@supports (display: grid) {

.yourdivclassname {
   display: grid;

}
}

This approach has helped me maintain consistent webpage designs across different browsers. I typically start with the grid layout, fine-tune it, then replicate it using Flexbox by substituting references to Grids.

If you need resources on Flexbox, I recommend this helpful tutorial: Flexbox Tutorial

For those interested in learning about Grids, check out this comprehensive guide: Grids Tutorial

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

I seem to have misplaced the textbox and the images are all jumbled up on my

I'm currently learning how to create a basic webpage with CSS. My goal is to make it look like this: I highlighted the class name in red However, when I entered the following code: <!DOCTYPE html> <html lang="es-ES"> <html> < ...

The Stripe card element seems to be missing from the form

I'm a newcomer to angularjs and currently working on integrating version 3 of the stripe api into my angular application. I followed the steps provided on the stripe website, but faced an issue when trying to incorporate their code which is primarily ...

Tips for ensuring that content doesn't shift down when clicking a drop-down menu

I currently have three dropdowns that function as an accordion. When I click on one dropdown, the rest of the content below shifts down, which is not the behavior I want. Is there a way to prevent the content below each dropdown from moving when a dropdow ...

Broaden the default className attribute of the component

Greetings! I'm currently using Bootstrap with React and I am trying to figure out how to extend my component by passing className props deeper. Within my atom component, I have two separate files. The first one contains the component declaration. B ...

Refresh the data in a table upon clicking the menu

I am looking to develop an accordion MENU, but unsure if I should use divs or <ul>. When a submenu is clicked, I want to execute a mysql query to update the data in the table next to the menu. I'm not sure of the best approach and whether to uti ...

Having trouble with the Image Path not connecting from the backend to the frontend of my application

I have been working on getting photos from my backend server and displaying them on my website. The images are stored in the API with a path that looks like localhost:44333/Images/[imagename]. On the frontend, I have tried adding the path dynamically, as ...

Unveiling the secrets to isolating elements from a list based on distinct characteristics

Currently, I am attempting to scrape job skills from the Wuzzuf website using the following code snippet: result = requests.get("https://wuzzuf.net/search/jobs/?q=data+analysis&a=navbl") src = result.content soup = BeautifulSoup(src, "lx ...

What is the best way to implement seamless transitions between different components in my code?

I'm currently developing my own single page application and I want the content to have a smooth animation effect as I scroll down, instead of being static. Despite searching for guides on this topic, I haven't found any helpful resources yet. An ...

Use Jquery to revert the chosen element back to its original base state

I have implemented a select box where selecting a value in the main select box "Domains" will reveal another select box called "Types" such as Diatoms or Flagellates. I have successfully achieved this functionality, but now I am facing an issue with resett ...

What is the best method for efficiently wrapping contents within a div container?

On the website cjshayward.com/index_new.html, there is a div wrapped around the content of the body, which is approximately 1000 pixels wide. In Chrome and Firefox, the wrapper works perfectly for the top section of about 100 pixels. Further down the page, ...

Achieve equal height columns when they are stacked vertically using Bootstrap 5

Can columns be equal height when they become rows on mobile devices? <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="57353838232423253627176279677965">[email protected]</ ...

Creating a personalized notification box that is compatible with various screen sizes and web browsers on android devices with the help of

After successfully implementing a custom alert box to hide the header with JavaScript, I encountered an issue when trying to use it on different browsers and Android devices. The alert box appeared misplaced on the page and was too big for certain Android ...

Adding a JavaScript global variable into a <div> element within the HTML body

Here is an example HTML tag: <div data-dojo-type="dojox.data.XmlStore" data-dojo-props="url:'http://135.250.70.162:8081/eqmWS/services/eq/Equipment/All/6204/2', label:'text'" data-dojo-id="bookStore3"></div> In ...

An elusive error detected within a JavaScript try-catch block

Attempting to implement a simple try{}catch{} block with the following code: try{ var invoice = parseInt(localStorage[0]); if(invoice == NaN) throw "invoice not a number"; localStorage[invoice] = Ticket; console.log("localStorage["+ ...

What is the reason for the position of div1 not being directly in the top right corner when its position is set to div2's top and left offset plus div2's width?

function handler(ev) { var target = $(ev.target); if( target.is(".item") ) { var brt = $(target).offset().top; var let = $(target).offset().left + $(".test").width(); $('#DivToShow').css({'top':brt,'left':let, 'd ...

Manipulating HTML elements while inside an SVG tag: a comprehensive guide

Having limited experience with .svg files and tags, I'm trying to achieve something simple but have been unable to find the exact solution after spending hours searching online. Can anyone provide some assistance? I have a basic svg file with an imag ...

Bootstrap: Create a square by setting the height equal to the width of the .span2 element

I'm looking to create a div that is the height of a ".span2" (essentially a square) and is also responsive. Here's what I have so far: <div class="span2 square>Hello</div> .span {height: @span2;} However, I haven't been able to ...

Delete the content within the span tag

Is there a way to remove the time + icon displayed on my blog page? <span><i class="fa fa-newspaper-o"></i>47 sec read</span> I attempted to use .fa-newspaper-o{display:hidden} however, this only hides the icon before "47 sec" b ...

iOS Font Display Issue in Ionic 2

I am currently in the process of developing an app using Ionic 2 and I want to incorporate a custom font called Quicksand. Here is how my folder structure looks: src | |-app | | | -app | | | | | -app.scss | | | -pages | | | -assets | ...

What is the best way to ensure my gif shows up in the top row and spans two columns in this grid?

I am attempting to create cards with a unique design where the first row consists of 2 columns, one being a GIF that shows the card fitting into a cell with a border. However, all I see is an empty cell without any display. Below is the code snippet I am ...