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

padding right and bottom gone on fixed element

I have a div .modal that has a fixed position with padding: 90px;. There is a div .child inside it with height: 1500px;.

The problem is that the padding right and bottom gone on modal, I have tried to set box-sizing: border-box; but it cannot solve the problem.

If you inspect it, there are negative value applied on position, I don’t know why.

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

.modal {
  background-color: gray;
  height: 100vh;
  padding: 90px;
  position: fixed;
  width: 100vw;
}

.child {
  background-color: orange;
  height: 1500px;
  width: 100%;
}
<div class="modal">
  <div class="child"></div>
</div>

Padding should be present no matter the value of the height of the content.

>Solution :

 * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.modal {
  background-color: gray;
  height: 100%;
  padding: 90px;
  position: fixed;
  width: 100vw;
  overflow: auto;
}

.child {
  background-color: orange;
  height: 1500px;
  width: 100%;
}
<div class="modal">
  <div class="child"></div>
</div>

Try this

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