Using CSS Grid in Combination with Absolute Positioning in Safari

Encountering an issue with a css grid layout.

The grid container is positioned absolutely and the grid-template-rows includes a 1fr to allocate space for one row to take up all available space.

While this renders correctly on most browsers, it fails to display properly on the latest version of Safari in macOS 10.13.2

The problem appears to be related to the calculation of free space when the height is not explicitly set.

Is there something I am overlooking or is there a workaround available?

Example on jsfiddle

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

.wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-rows: 1fr 150px;
  grid-template-columns: 1fr 150px;
  grid-template-areas: "a b" "c d";
}

.wrapper>div {
  outline: solid 1px #aaa;
  padding: 10px;
}

.game {
  grid-area: a;
}

.player {
  grid-area: b;
}

.rules {
  grid-area: d;
}

.controls {
  grid-area: c;
}
<div class="wrapper">
  <div class="game">game</div>
  <div class="player">player</div>
  <div class="rules">rules</div>
  <div class="controls">controls</div>
</div>

Answer №1

As we approach 2020, using top: 0; bottom 0 to adjust positioning seems outdated. Instead, consider setting the minimum height of the .container to match 100% of the viewport - 100vh for a cleaner solution.

.container {
  min-height: 100vh;
}

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

Retrieve JSON information using PHP and JavaScript SDK exclusivley

After successfully setting up the Facebook Javascript SDK and getting it to display the right information on the page, I have also managed to echo the user into the Firebug console to show the Object containing all of the user profile details. * I am opti ...

The .map() function seems to be missing some data when fetching from the database in a Node.js

I am currently tackling an exercise for a Bootcamp, and the function I am using is not yielding the desired outcome. The objective is to query the database with a first name or a part of a first name. While I can successfully execute the DB query and retri ...

Can we find a more effective solution for addressing npm vulnerabilities?

I'm currently facing challenges with resolving the vulnerabilities within my expo React Native project. This is an ongoing development project utilizing React Native technology. Every time I encounter the following issues; up to date, audited 1375 pa ...

Why can't I capture the text within this particular div using .text?

Trying to extract specific text from a website in Chrome's developer console. For example, here is the code snippet: <div class="someClass">This is some text!</div> Expected it to work with this command, but it returns 'undefined&a ...

Failure to apply Bootstrap Stylesheet

On certain pages, I have included Bootstrap. On one particular page, I have an alert styled with Bootstrap. This is how it's defined: $('#wrongPasswordDiv').html('<br/><div class="alert alert-danger" id="wrongPWAlert" role= ...

Is there a built-in Bootstrap class that can enable a full view height setting?

I added this CSS class to my code: .full-view-height { min-height: 100vh; } After many searches online, I couldn't find an equivalent Bootstrap class. Is there a default class in Bootstrap 4 that serves the same purpose? ...

Redis appears to be missing the expected results

After following an express demo which involved storing and retrieving values with Redis, I attempted to implement the code in my own Express app. However, I encountered issues as the req.online variable was returning null when I tried to retrieve its lengt ...

"Using Vee-validate to validate on blur can help avoid submitting a form with

Currently, I have implemented vee-validate to validate a form in vue.js. The validation is set to trigger on blur, and there is also a submit button that should validate all fields in the form upon clicking. The problem arises when I click the submit butt ...

Include an option for whitespace characters when validating a file using regex

My text box has specific criteria for what is considered good or bad input. Examples of good input could include: GoodString GoodString88 99GoodString I want to avoid certain types of bad input, such as: Good*String Good&String However, I do want ...

Error encountered in React Material UI: Appbar - TypeError occurred when attempting to read properties that are undefined (specifically, reading '100')

Currently, I am working on developing a multi-step form using Material UI components. However, upon importing the necessary components, an error is being displayed in my code snippet: import React from 'react'; import { ThemeProvider } from &a ...

When an attempt to make a POST request using fetch() is made, a TypeError: Failed to fetch error is immediately thrown instead of

My front-end form is posting data using the fetch() function. Everything works fine and I get the correct response from the server when it runs smoothly without any interruptions. However, when I debug the server endpoint, it throws a TypeError: failed to ...

Encountering a "Start script missing" error while trying to execute npm start, the problem remains even after attempting

Help, I keep encountering this issue npm ERR! missing script: start whenever I attempt to execute 'npm start' for my latest React project. I've tried searching for a solution and came across some individuals who were able to resolve it by u ...

By simply clicking a button, you can input a value into a field without the need for the page to refresh

Can someone please help me figure out how to insert a specific value into an input field without refreshing the page? I have tried the following code but it doesn't seem to work. Basically, when I click the button, I want the value "1234567" to be aut ...

Challenges with resizing in Bootstrap

I need assistance with my login form that is appearing in a Bootstrap modal. The modal I am using is the standard size, not the larger one. In the form, there are 2 input fields and a login button on the left side, while the right side should contain other ...

What is the best way to verify the status codes of multiple URLs using JavaScript?

In my JavaScript project, I am currently checking the status codes of various URLs. While I can successfully check the status for one URL at a time by writing the code manually, I am facing an issue as I have over 100 URLs to check. This is making my cod ...

Unable to cancel the RTK query request

It's quite a dilemma. I need to handle the request differently when there is no user present. I've attempted different approaches like this and that const { data: carts = [] as ICart[], isFetching } = api.useGetCartProductsQuery(user.id, { skip: ...

Update submenu panel in jQuery Mobile version 1.4.3 following AJAX request

Hello there, I am currently in the process of developing my first JQuery Mobile website. One of the key features I have implemented is a panel for navigation. Each individual page includes the panel, along with an icon in the header that serves as the butt ...

Guide on simulating an incoming http request (response) using cypress

Is there a way to mock a response for an HTTP request in Cypress? Let me demonstrate my current code: Cypress.Commands.add("FakeLoginWithMsal", (userId) => { cy.intercept('**/oauth2/v2.0/token', (req) => { ...

Compiling this HTML template in dev mode with Vue is agonizingly slow

I've been working with a template app setup that was bootstrapped using vue CLI. Within one of my components, I have 20 nested div tags. During development mode, it's taking roughly 10 seconds to compile this component. The more deeply I nest HTM ...

Retrieve the date and month information from the data-date-format

Can anyone help me figure out how to extract only the date and month from a bootstrap date picker and assign them to variables? <div class="input-append date dp3" data-date-format="dd.mm.yyyy"> <input class="span2" size="16" type="text" id="R ...