elad2412 / the-new-css-reset

The New Simple and Lighter CSS Reset
https://elad2412.github.io/the-new-css-reset/
MIT License
2.25k stars 229 forks source link

CSS Grid First Element height breaks with "all:unset;" #82

Closed DrEVILish closed 12 months ago

DrEVILish commented 12 months ago

Using Brave ([Version 1.60.114 Chromium: 119.0.6045.124 (Official Build) (arm64)] Using Firefox 119.0.1 (64-bit)

With CSS reset applied the first Row gets the wrong height applied in the CSS Grid, when trying to auto-height the rows to fill vertical space.

*:where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) { all: unset; }

Currently causing an issue with heights of elements in CSS Grid:

.container {
   height: 100vh;
}

.drivers {
    display: grid;
    grid-template-rows: min-content; //makes the rows fit the height of the container
}

.driver {
    display: grid;
    grid-template-columns: 4vb 1fr 1fr 5vb 1vb;
    grid-template-rows: 1fr;
    justify-content: center;
    align-items: center;
}

<div .container>
<div .drivers>
<div .driver> DAVE </div>
<div .driver> STEVE </div>
<div .driver> MIKE </div>
<div .driver> McQueen </div>
</div>
</div>

**above should be all the relevant code please let me know if unable to reproduce.

Separately with all: unset; commented out, neither: * { margin-top: 0; } * { margin-bottom: 0; } cause the issue but together margin: 0 and margin-top: 0; margin-bottom: 0; causes the issue.

graymatter00 commented 12 months ago

@DrEVILish Perhaps providing a codepen example would be helpful.

DrEVILish commented 12 months ago

https://codepen.io/DrEVILish/pen/abXWgRq

graymatter00 commented 12 months ago

@DrEVILish I might be missing something here or misunderstanding what you want to achieve, so apologies if on the wrong track.

Grids can be tricky. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid

DrEVILish commented 12 months ago

There is definitely some strange behaviour with CSS grid.

The aim was to get the "drivers" to fill the remaining space, so if another element poped above they would responsively change size.

I've swapped to use

.drivers {
    display: flex;
    flex-direction: column;
}
.drivers .driver {
    flex-grow: 1;
}

worked straight time with no weird quirks.

Deffo an upstream bug, it would come and go when I commented in and out the { all: unset; } line.

Issue Closed.