cssgrid-ama icon indicating copy to clipboard operation
cssgrid-ama copied to clipboard

Correct way of display a responsive CSS Grid with header overlay

Open EVO-9 opened this issue 8 years ago • 4 comments

Hi

I'm starting to get to grips (well i hope so) with CSS Grids but i'm not sure i'm using it correctly. I've been following gridbyexample and there seems to be quite a few ways when placing columns and rows and i'm now confused.

Please see my code here: https://codepen.io/juanmata/full/zwdvxz/

I seem to be getting the effect I want although I'm not sure the code is correct, should I be using grid-template-areas and if so how do I do it when the header is overlaying the other content.

There is also an issue with grid rows, I seem to have to add extra lines of code for the @media queries so there's no gap i.e. when the browser's width is above 992px and the 4 previous grids are on one row, I need to add a lower grid number for footer otherwise it leaves a row.

How would you code the above?

EVO-9 avatar May 03 '17 12:05 EVO-9

Apologies, just realised I deleted the example by accident.

After playing about more with css-grid, I hope this is the correct way of writing the code.

Basically, I am wanting a full screen hero image 100% height and width with an 80px header hovering over the image, finally a footer which will sit under the hero and will be displayed when you scroll down.

In order to do this I have had to use calc(100vh - 80px) within grid-template-rows which i'm not sure is the correct way to do it? If i just use 100vh it doesn't calculate the 80px header which hovers over the main content.

Please find the new example here: https://codepen.io/juanmata/pen/RVMbmr

Once I have achieved this, next on my list is a responsive touch slider using css-grid.

EVO-9 avatar May 11 '17 00:05 EVO-9

Also, do transitions not work with css-grid?

I am trying to make the header sticky and make smaller when scrolling down the page, i've got this working but the transitions won't work? See the above example for a working version.

EVO-9 avatar May 11 '17 10:05 EVO-9

Please ask one question at a time, including a reduced test case. So simplify your example right down to the bare minimum needed to show the issue.

rachelandrew avatar May 13 '17 12:05 rachelandrew

@juanmata09 Unfortunately CSS transitions don't work on CSS Grids. Hopefully it will be added at a later stage.

Personally I don't think there's anything "wrong" with the way you added a calc() for your rows... it works fine and I don't see any reason it would cause problems with maintenance or anything. However I did come up with a slightly altered option:

https://codepen.io/IOIIOOIO/pen/POzxzq

IOIIOOIO avatar Nov 06 '17 16:11 IOIIOOIO