Discrepancies in display grid rendering in Firefox versus Chrome

I'm experimenting with creating a master-detail view by showcasing two CSS tables (display:table) side by side. To organize the layout, I've implemented CSS Grid.

The master panel typically contains 1 to 10 rows while the detail content can exceed 50-60 rows.

Check out my CodePen for reference: https://codepen.io/rahuldj/pen/ExYPpGm

While everything displays correctly in Chrome, I encountered an issue in Firefox where the table with fewer rows expands to match the height of the longer table.

I attempted to set specific heights for rows, but it seems that Firefox disregards these settings when the parent element is a grid. Any ideas on how to resolve this?

Here's the HTML structure:

<div class="grid">
  <div class="table">
    <div class="th">
      <div>Column 1</div>
      <div>Column 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
  </div>
  <div class="table">
    <div class="th">
      <div>Column 1</div>
      <div>Column 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <!-- Additional rows here -->
  </div>
</div>

CSS Styling:

.grid{
  display:grid;
  grid-template-columns:0.3fr 0.7fr;
  grid-column-gap:30px;
}

.table{
  display:table;
  width:100%;
}

.th {
  display:table-row;
  font-weight:bold;
}

.th > div{
  display:table-cell;
}

.row{
  display:table-row;
}

.row > div{
  display: table-cell;
}

Answer №1

In Firefox, the min-height property does not work on table elements, including td. This is because a table cell will always stretch if necessary, so the height property acts like min-height for a table cell. The table-cell property makes an element behave like td, so it follows the same principle. To fix this issue, try giving your table a specified height to ensure it extends automatically. I had success using the following code in Firefox:

.grid{
  display:grid;
  grid-template-columns:0.3fr 0.7fr;
  grid-column-gap:30px;
}

.table{
  display:table;
  width:100%;
  height:55px;
  background-color:lightgreen;
}

.th {
  display:table-row;
  font-weight:bold;
}

.th > div{
  display:table-cell;
  height: 31px;
}

.row{
  display:table-row;
}

.row > div{
  display: table-cell;
  height:31px;
}
<div class="grid">
  <div class="table">
    <div class="th">
      <div>Column 1</div>
      <div>Column 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
     <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
     <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
     <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
     <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
  </div>
  <div class="table">
    <div class="th">
      <div>Column 1</div>
      <div>Column 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
    <div class="row">
      <div>Data 1</div>
      <div>Data 2</div>
    </div>
  </div>
</div>

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

Creating movement in three distinct divisions

I am seeking a way to have three divs flying in upon click. The first DIV is positioned at the top, followed by one on the left and one on the right (both being below the top one). I wish for them to fly in from their respective directions - the top div fr ...

What are the steps for adding information to a MySQL database with GWT, HTML, and either JDBC or Hibernate?

I have been working with GWT (Google Web Toolkit) version 2.5.1 and successfully developed a sample application to display the username and password. However, I am now facing challenges in inserting these values into a MySQL database table using JDBC or Hi ...

Designing a dropdown menu with sub-menus that appear when hovered over

In my quest to design CSS that will dynamically display links in left-to-right divs, I am seeking a way for sub-menus to appear below the menu being rolled over. The challenge lies in the fact that these menus will be loaded from a WordPress database, mean ...

Problem with displaying information in the table based on the numerical input

How can I dynamically set the number of rows in a table based on an input field? var app = angular.module("myApp", []); app.controller("myCtrl", function($scope) { $scope.myObj =[ {"Name" : "Alfreds Futterkiste", "Country" : "Germany","City" : "Berlin ...

Seeking assistance with printing an HTML template using a printer in Angular 2. Can anyone provide guidance on how

I have a scenario where I need to print an HTML template from within my Angular 2 component. Specifically, I want to be able to click on a print button on the same page and trigger the print function, which would display a print preview and allow the use ...

Learn the method for printing CSS outlines and background colors in IE8 using JQuery's printElement feature

Printing my HTML calendar table in Chrome results in a perfect display. However, when I try to print it in IE8, the background colors and images are not included. Despite following steps from a helpful post on setting it as the default option, there were n ...

Blazor components experience element interaction while utilizing more than one instance of Blazorise.Bootstrap component

I am facing an issue in my Blazor app where a component with a button and bootstrap collapse works fine when used once on a page, but triggers collapse elements in other instances when used multiple times. This seems to be happening because their IDs are s ...

When attempting to access the callback response with HTML tags from the server, the AJAX request in jQuery fails

I am currently facing a challenge while working on an ajax form submission that returns Json response. Everything functions smoothly except for a specific situation where I need to include HTML content in the response, such as a URL link for users to acces ...

Take the attention away from the canvas

Is there a way to shift focus away from the canvas and onto input fields in my HTML code? Right now, the canvas is holding onto focus even when I'm clicking on text inputs. This prevents me from typing anything into them. Ideally, I'd like for t ...

Adjusting the height of one element based on the height of another element in multiple cases using jQuery

I am currently using jQuery to retrieve the height of one div and apply that value as a CSS property to another. Let's take a look at a sample layout: <div class="row"> <div class="column image"> <img src="image.jpg" /> < ...

Unable to alter background color of checkbox with jQuery slide toggle

I've been working on changing the background colour of the toggle button to green when it's turned on. I feel like I've followed all the correct steps, but for some reason, the background just stays grey. Can anyone point out what might be ...

Make sure to consistently show the rating bubble within the md-slider

I am currently exploring the functionality of md-slider in its md-discrete mode. However, I would like to have the slider bubble always visible on the screen, similar to this: I do not want the slider bubble to disappear when clicking elsewhere. Is there ...

Sliding the content in React

My current project involves creating a content slider in React. While I have made some progress, I am facing a challenge in making the content move horizontally instead of vertically. Currently, all the items are stacked on top of each other, preventing th ...

The webpage is experiencing a glitch as the favicon fails to appear

I am having trouble showing a favicon on my website. I'm currently using IE8 as my browser. In my .aspx page, I have included the following markup: <head runat="server"> <link rel="shortcut icon" href="Images/favicon.ico" /> </head&g ...

Ensure that the next iteration of .each() does not begin until all nested functions have finished executing

Is there a way to ensure that my .each() function waits for all nested functions to complete before moving on? Here is the code I am working with: HTML: <div> <p>Text 1</p> <p>Text 2</p> <p>Text 3</p> & ...

Automate tasks without the need for a traditional form, simply using a text box and a

I've exhausted my search efforts on Google, looking for answers to any question relating to my issue. The webpage I am attempting to submit resembles this setup: there is no form present and the objects are not organized within a form structure. While ...

Unraveling the mystery behind table cells failing to wrap their content when set to 100% height

Original inquiry (REVISED) CSS: Why does a table-cell sibling with a height of 100% exceed the body of the table-row? Experimenting with CSS tables, I am striving to achieve an evenly spaced column layout. I aim to have an "aside" on the left side th ...

Do we always need to incorporate components in Vue.js, even if there are no plans for reuse?

I've been pondering this question for some time now: is it necessary for every component to be reusable? Consider a scenario where we have HTML, CSS, and JavaScript that cannot be reused. For instance, a CRUD table designed specifically for managing u ...

The back to top feature is malfunctioning when navigating to a new page

I've been working with jQuery Mobile to create some pages and wanted to add a "back to top" element. It's been functioning well, but I've encountered an issue. When I navigate from one page, let's say #sport, back to #restaurants after ...

Checkbox click event not triggering properly

I am facing challenges in triggering an onclick event for the "Elevation" checkboxes located at the URL provided above. <input type="checkbox" value="A" id="elevation_A" onclick="changeElevation(this.value);" /> For some reason, the "changeElevati ...