Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected 1 pixel margin in Edge browser

I am having an unexpected 1px margin under a div residing in a fixed container. This issue only occurs in Edge (possibly in IE as well). After some testing, I was able to reproduce the bug with a bare bones example.

This picture, which you can reproduce running the snippet below, is composed of 3 square divs inside a fixed div. Firefox

enter image description here

In Edge, you can "fix" this issue by either disabling the property top: 50% in the container div, or by disabling border-*-right-radius: 6px in the divs inside it. Naturally, this isn't a fix, because I need both these properties to effectively implement this design.

How can I fix this? I tried adding borders the same color as the background, but the background is not opaque.

Edit: If you can't see it right away in IE/Edge, try to select the container div and slowly increase the value of the top property. In IE11, changing it from 5% to 6% already made the problem obvious again.

.box {
  background-color: rgba(0,0,0,0.15);
  height: 70px;
  line-height: 70px;
  text-align: center;
  border-right: 1px solid rgba(0,0,0,0.2);
}
.box:hover {
  background-color: rgba(50,50,100,0.15);
}
.box:first-child {
  border-top-right-radius: 6px;
  border-top: 1px solid rgba(0,0,0,0.2);
}
.box:last-child {
  border-bottom-right-radius: 6px;
  border-bottom:1px solid rgba(0,0,0,0.2);
}

.main {
  width: 70px;
  position: fixed;
  left: 0;
  top: 5%;
}
<div class="main">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div>
like image 962
ecc Avatar asked Sep 15 '15 14:09

ecc


2 Answers

Try to use border on parent div: http://jsfiddle.net/gtf0fa8n/1/

Border radius on parent does not brake inner divs rendering in IE

.main {
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-left: 0;
    border-radius: 0 6px 6px 0;
    overflow: hidden;
}

.box {
    background-color: rgba(0, 0, 0, 0.3);
    height: 70px;
    line-height: 70px;
    text-align: center;
}
.box:hover {
    background-color: rgba(50,50,100,0.15);
}
like image 69
IonDen Avatar answered Nov 15 '22 08:11

IonDen


Just give boxshadow of 1px with same color on bottom.

box-shadow: #2a2e37 0px 1px 0px;
like image 28
Ammar Avatar answered Nov 15 '22 07:11

Ammar