前景提要
<style> *{margin: 0;padding: 0;} .box{display:flex;width:600px;height:300px;} .left{ flex-grow: 0.991; width: 100px; background: green; } </style> <div class='box'> <div class="left" id="left"></div> <script> console.log(document.getElementById('left').getBoundingClientRect().width) //595.484375 </script> </div>
在 chrome 打印出来 width 为 595.484375 。 按照 flex 的规范 width 应该为 100+(500*0.991)=595.5 chrome devtools 显示的 width 为 595.48.为什么会出现这种情况啊?