Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove grid gap / padding?

I want to divide body into 2 parts without any padding or gap.
But when I divide body by grid.

It shows me some gap even if I set grid-gap as 0.
It should show left as whole blue and right as whole white.

How to remove those gaps?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

enter image description here

body {
    width: 100%;
    height: 100vh;
    background-color: #5FAAD9;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-column-gap: 0;
    gap: 0;
}

#Record {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#List {
    width: 100%;
    height: 100vh;
    background-color: white;
}

>Solution :

You have 20px padding on the left item but not on the right item.

The padding is not being counted in the height of the left item because the default setting for box-sizing will be being used.

You can make that padding be included in the dimensions of the item by setting box-sizing: border-box;

This snippet also sets the margins of all elements to 0 initially so as to remove the small (normally 8px) margins around the body.

* {
  margin: 0;
}

body {
  width: 100%;
  height: 100vh;
  background-color: #5FAAD9;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-column-gap: 0;
  gap: 0;
}

#Record {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
}

#List {
  width: 100%;
  height: 100vh;
  background-color: white;
}
<body>
  <div id="Record"></div>
  <div id="List"></div>
</body>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading