2

When I have a parent element with a border, and an element on the inside, there is always a little white gap on all sides. This is despite me setting the inner padding and outer margin both to 0. Example:

#outer{
    height:10px;
    width:200px;
    border:2px solid black;
    overflow:hidden;
    border-radius:999px;
    padding:0;
}
#inner{
    width:100%;
    height:100%;
    background-color:red;
    margin:0;
}
<div id="outer">
    <div id="inner"></div>
</div>
Lucien950
  • 195
  • 2
  • 10

1 Answers1

2

Use outline instead of border.

ref: What is the difference between outline and border CSS properties?

#outer{
    height:10px;
    width:200px;
    outline:2px solid black;
    overflow:hidden;
    border-radius:999px;
    padding:0;
}
#inner{
    width:100%;
    height:100%;
    background-color:red;
    margin:0;
}
<div id="outer">
    <div id="inner"></div>
</div>
Newo
  • 48
  • 5