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;
}
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.
'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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With