The CSS grid header is malfunctioning on Chrome and Opera, while functioning correctly on Firefox

My first attempt at creating a website layout using grid was successful in Firefox, but not in Chrome and Opera. The header is taking up only about 1/3 of the width, leaving the rest empty on these browsers. However, everything else, including the mobile layout, seems to be working fine. I have checked that all my browsers are up to date.

I am unsure how to address this issue.

div.container {
display: grid;
grid-template-columns: auto 1fr auto;
grid-template-rows: auto 1fr;
grid-template-areas: 
"site-header site-header site-header"
"site-nav content sidebar";
grid-gap: 0;
max-width: 100%;
min-height: 100%;}

.site-header {
grid-area: site-header;
height: 250px;
border-bottom: 2px solid #999;
text-align: center;
display: table;
background-color: green;}

Answer №1

Could it be an issue with the display: table property within a Grid layout? It seems that in your case, Chrome is calculating the width as 0.

Try setting the width property explicitly to see if that resolves the issue.

Check out this fiddle for more details.

div.container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr;
  grid-template-areas: "site-header site-header site-header" "site-nav content sidebar";
  grid-gap: 0;
  max-width: 100%;
  min-height: 100%;
  background: grey;
}

.site-header {
  grid-area: site-header;
  height: 250px;
  border-bottom: 2px solid #999;
  text-align: center;
  display: table;
  background-color: green;
  width: 100%;
}
<div class="container">
  <header class="site-header"></header>
</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

Align the content to the center of the middle column using HTML

Is it possible to replicate Amazon's email structure using only HTML in the feedbackwhiz template editor? I want my content to be left-justified in the center column with white space on either side, similar to the Amazon email example provided. Amazo ...

The text feature for the Google Places API is not displaying properly within the MUI TextField

For address auto-generation, I am currently utilizing the Google Places API. I have a regular input tag in my HTML where users can type their input and see Google Places suggestions in the dropdown - all working perfectly. However, when I switch to using m ...

history.js - failure to save the first page in browsing history

I have implemented the history.js library to enable backward and forward browser navigation on an AJAX products page triggered by clicking on product categories. While I have managed to get this functionality working smoothly, I am facing a particular iss ...

Eliminate a row in an HTML table depending on a certain condition

I have an HTML table that I am dynamically adding values to: <TABLE id="dlStdFeature" Width="300" Runat="server" CellSpacing="0" CellPadding="0"> <TR> <TD id="stdfeaturetd" vAlign="top" width="350" runat="server"></TD> < ...

What is the best way to create interactive canvases that respond to multiple clicks using JavaScript?

Within the canvas, the code snippet below aims to generate a grid of 10x10 colored boxes with alternating reddish and bluish shades on a gray background. The intention is for each canvas to only respond to mouse interactions when the mouse is within its bo ...

Enhance the HTML content using a JavaScript function

Here is the code that I have: <label>Brand</label></br> <select name="brand" id="brand" onChange="changecat(this.value);"> <option value="" selected>Select Brand</option> <option value="A">AMD</option&g ...

Utilize the jQuery autocomplete UI Widget to trigger a select event on a dynamically generated row in a table

Currently, I have successfully implemented a jQuery autocomplete feature on the text input of a table data element called txtRow1. The data for this autocomplete is fetched remotely from a MySQL database and returned in JSON format as 'value' for ...

Update the CSS styles using jQuery

I am looking to update the content within a CSS tag using jQuery. In this instance, I need to change "My content" to "New Content". Here is the CSS code I have: a.appari:focus:after{ background: #333; background: rgba(0,0,0,.8); border-radius: 5px ...

When trying to set the focus on the first item in a list using HTML and Angular, the focus unexpectedly shifts to the second

I've been tackling a UI requirement where the focus needs to be set on the first element of a list item constructed from an array of objects when the tab key is pressed for the first time. Subsequent tab key presses should cycle through the list items ...

Center aligning elements in React using CSS with HTML can be achieved through Flexbox. However, sometimes images

Currently, I'm in the process of developing a website with react and I've encountered an issue with centering elements vertically on the left and right sides. It's been troubling me for a few days now and I haven't found a solution yet. ...

What is the best way to insert identical text into several lines at once using emacs?

My HTML file contains numerous links to a database, but the URLs are formatted as: <a href=/bw/examplefile.html> Although I attempted to use wget with the --base parameter to download all the links, it didn't work as expected. Instead of trou ...

The DIV element fails to encompass all of its content

There seems to be an issue with the only div element on my page. It's covering the middle of the page, but I managed to make it extend all the way down using CSS tweaks. However, there is a problem - the video inside the div is overflowing: Below is ...

Tips for invoking a JavaScript class method from an HTML document

I've created a Typescript class that dynamically inserts an HTML element to a page after it's loaded. Here is the code snippet: const calcElement: string = ` <div class="container"> <span class="cc-title">Field</span> ...

Animate the jQuery display property to show a table without changing any specified spatial dimensions

When utilizing jQuery's $.animate() on an element styled with display:table, any spatial dimensions that are not explicitly specified to change will animate. Check out the fiddle here In the scenario presented, the width is defined for animation, bu ...

"Redirecting visitors based on their location using GeoIP targeting for

Is there a way to implement a code that redirects users based on their location? For example, if a user accesses the site from the United Kingdom, they should be redirected to /UK/, if from the US to /US/, and if from anywhere in the EU (excluding the UK) ...

What is the purpose of the HTML span tag?

Is it possible to group multiple anchor tags and another span tag within a single span tag? Check out the HTML code below. <span> <a href="#">link</a> <span>|</span> <a href="#">link</a> <a hre ...

Enhancing dynamic text boxes with jQuery by incorporating additional information

I've recently developed an interactive app that dynamically creates tables based on user input. The app includes a feature where you can specify the number of tables to generate and track the total count of tables added. Currently, I'm exploring ...

Issue with AngularJS: Local storage not saving updated contenteditable data

My local storage implementation stops working when I attempt to incorporate contentEditable feature. Here is the link to the CodePen for reference: https://codepen.io/zanderbush/pen/WNwWbWe. Any assistance would be greatly appreciated. The functionality w ...

Utilizing $.each to dynamically add data to a jQuery Mobile listview

Trying to implement a data reading mechanism using ajax resulted in unexpected html tag generation for <ul> <li>. The code snippet is as follows: (function( $, undefined ) { $(document).on("pagecreate", ".jqm-demos", function(){ ...

Generate HTML content based on the permissions from a REST API

I have a frontend that renders based on user permissions from a REST API. These permissions could include deleting users, creating users, adding users to workflows, and more. Most of these permissions are managed by an administrator. So my question is: H ...