css - 相同的 CSS,相同的页面,不同的渲染
问题描述
谁能解释下面显示的这种差异的原因?
在底部面板中,彩色条比顶部面板更厚。
两者的 CSS 相同;
.colored-bar {
width: 100%;
height: 2px;
}
浏览器:Chrome 84
请在此处查看实时重现:CodePen
我在 CodePen 中看到的;
解决方案
可能您在浏览器中打开了放大功能。禁用它,一切都应该是正确的。
125% 的放大率显示与您的屏幕截图完全相同的问题。
更新1:
此外,如果我直接在 Windows 屏幕设置中将缩放设置为 125%,则会出现问题。
更新 2:
我可能会找到一个可能的解决方案。只需使用伪元素而不是普通元素,一切似乎都运行良好,但我没有进行广泛的测试。
.kpi {
border: 1px solid black;
height: 56px;
width: 175px;
padding: 10px;
}
.box {
display: flex;
flex-direction: column;
width: 45px;
height: 50px;
text-align: center;
}
.box::after {
content: '';
width: 100%;
border-bottom: 2px solid #0f0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex space-between">
<div class="col d-flex flex-column justify-content-between">
<div class="row kpi mb10 d-flex justify-content-between">
<div class="box">
Test
</div>
<div class="box">
Test
</div>
<div class="box">
Test
</div>
</div>
<div class="row kpi mb10 d-flex justify-content-between">
<div class="box">
Test
</div>
<div class="box">
Test
</div>
<div class="box">
Test
</div>
</div>
</div>
</div>
推荐阅读
- point - QGIS中点层对某些投影的条带问题
- javascript - Joi 条件 .required()
- javascript - 任务。js购买后如何查出用户钱包里剩余的金额
- node.js - elasticbeanstalk上的节点服务器,server.ts,502 Bad Gateway
- android - Azure DevOps AndroidSigning 任务未签署 APK
- python - Conda UnsatisfiableError 即使看似没有任何冲突
- javascript - 使用 Ramda 从数组或 null 中获取第一个元素
- javascript - 谷歌图表重复hAxis
- laravel - 如何通过 IP 地址在 Apache2 上服务 Laravel 8 项目?
- mysql - 如何在mysql中获取具有相同工资值的第二个员工姓名的最低和最高工资的员工姓名?