Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

402
Views
How to fully fill child div in div with borders in Chrome?

I have a problem. I need to fill image in div with borders, but in Chrome 96.0 i see some inside margins from top and left, and don't know how to delete them.

This is my code:

.wrapper {
  width: 36px;
  height: 36px;
  border: solid 2px red;
  padding: 0;
}

.img {
  width: 100%;
  height: 100%;
  background: green;
  margin: 0;
}
<div class="wrapper">
  <div class="img"></div>
</div>

What I see:

enter image description here

What my friend sees in Safari:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think it is rounding related issue: https://johnresig.com/blog/sub-pixel-problems-in-css/
It becomes clear when you change zooms levels.

As workaround we can set inset shadow on wrapper:

.wrapper {
  width: 36px;
  height: 36px;
  border: solid 2px red;
  padding: 0;
}

.img {
  width: 100%;
  height: 100%;
  background: green;
  margin: 0;
}

.shadow{
  /* add inset shadow to cover white gaps*/
  box-shadow: 0px 0px 2px 1px red inset;
 }
Normal output:
<div class="wrapper">
  <div class="img"></div>
</div>
<br>
With inset shadow:
<div class="wrapper shadow">
  <div class="img"></div>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!