Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

404
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda