I have div
inside another div
. If I have a border in the outer div
I got a space in Microsoft Edge browser in some scales (100% or 125%). I think it's a rounding bug, but I don't know how to get rid of it.
html:
<div class="outer">
<div class="inner"></div>
</div>
css:
.outer {
background-color: black;
float: left;
border: 1px solid white;
}
.inner {
width: 300px;
height: 300px;
background-color: yellow;
}
jsfiddle: https://jsfiddle.net/EvgeniiMalikov/4bbx9p5w/
As you can see there is black background visible between outer and inner div. If you don't see it try to change scale.
UPDATE: the gap really appears not between div elements, it's inside inner div close to its border. Discovered it by adding outline to inner div.
example screenshot
example screenshot with border and outline (gap between border and outline)
box-sizing: border-box;
border: 1px solid lime;
outline: 1px solid lime;
You can use line-height for decrease distance. Drawback of this method -- because we use block display it works only for single line of the text. Show activity on this post. You can use background with linear-gradient to produce a border, and with it you can position it anywhere.
There are two methods for removal of space between two divs or two elements. First one is, assign the font size of the parent of the inline block element to 0px and then assign the proper font-size to the inline block element. and Second is, Make the display of the parent element to flex.
You can achieve this by removing the margin from the H2 element using css. If you only want to remove the space from the top or bottom of the <h2> element you can use the margin-top and margin-bottom CSS properties.
The gap is the result of the margin of the paragraph escaping from its container. Give me a minute to look at the page and I'll offer more info. EDIT: @RyanReese nailed it. It's just a margin collapse issue.
the border 1px is adding to the width 300px. you need to remove 1px from the width
.outer{background-color: black; float: left; border: 1px solid white}
.inner{width: 299px; height: 300px; background-color: yellow}
Here is the screenshot from Microsoft Edge
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With