Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding to CSS Grid

I am a beginner to HTML and CSS, so I've been experimenting with the different systems like Flex and CSS Grid. I've run into an issue where I can't add padding to an element inside a Grid Column. Is there any way to fix this? When I try to add padding to the physical header itself it doesn't work because it's display grid, here's the code:

header{
    width:100%;
    height: 5%;
    color: #fff;
    background: #434343;
    display: grid;
    grid-template-columns: 2fr auto;
}


header:not(menu, h1, nav){
    display: block;
    padding:500px;

}
like image 982
Jordy337 Avatar asked Aug 15 '18 20:08

Jordy337


People also ask

What is padding in grid?

Use grid padding to increase the size of the space of gap between each column and row. Depending on your data set and design preferences, increasing the padding size can make for easier reading and comprehension, especially if used with other formatting options like alternate rows.

Is CSS grid gap deprecated?

'grid-gap' has been deprecated in favor of 'gap'. In a similar vein 'grid-row-gap' and 'grid-column-gap' have been deprecated in favor of 'row-gap' and 'column-gap'. Unfortunately, the new features aren't recognized by Visual Studio yet either. As far as May 2020, 'grid-gap' is shown as "Obsolete" in VSC.

What is 1fr in CSS?

With CSS Grid Layout, we get a new flexible unit: the Fr unit. Fr is a fractional unit and 1fr is for 1 part of the available space. The following are a few examples of the fr unit at work. The grid items in these examples are placed onto the grid with grid areas.


1 Answers

You can add padding between the grid containers using grid padding or row gap, depending on your needs.

gap

row-gap

column-gap

Otherwise I would need a more detailed question to solve your issue.

like image 179
Tanckom Avatar answered Sep 30 '22 20:09

Tanckom