gpt4 book ai didi

css - Edge 浏览器中意外的 1 像素边距

转载 作者:技术小花猫 更新时间:2023-10-29 11:03:42 26 4
gpt4 key购买 nike

我在驻留在固定容器中的 div 下有意外的 1px 边距。此问题仅出现在 Edge 中(可能也出现在 IE 中)。经过一些测试后,我能够用一个简单的例子重现这个错误。

您可以运行下面的代码片段重现这张图片,它由固定 div 内的 3 个正方形 div 组成。火狐

enter image description here

在 Edge 中,您可以通过禁用容器 div 中的属性 top: 50% 或禁用 border-*-right-radius: 6px< 来“解决”这个问题 在它里面的 div 中。当然,这不是解决方法,因为我需要这两个属性才能有效地实现此设计。

我该如何解决这个问题?我尝试添加与背景颜色相同的边框,但背景不是不透明的。

编辑:如果您不能立即在 IE/Edge 中看到它,请尝试选择容器 div 并慢慢增加 top 属性的值。在 IE11 中,将它从 5% 更改为 6% 已经使问题再次明显。

.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>

最佳答案

尝试在父 div 上使用边框:http://jsfiddle.net/gtf0fa8n/1/

父级的边框半径不会阻止 IE 中的内部 div 渲染

.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);
}

关于css - Edge 浏览器中意外的 1 像素边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32588526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com