简体   繁体   English

CSS - 显示:表,固定宽度得到小数

[英]CSS - Display: Table, fixed width getting a decimal

I am having an issue in Chrome where a fixed width div is not displaying properly. 我在Chrome中遇到问题,其中固定宽度div无法正常显示。 Please see my jsFiddle . 请看我的jsFiddle

I have three nested divs. 我有三个嵌套的div。

 .container { background: red; width: 375px; } 
 <div class="container"> <div style="display: table; width: 375px; background: red;"> <div style="display: table-cell; width: 375px; background: blue"> Content </div> </div> </div> 

I have also given class "container" a fixed width of 375px. 我还给了类“容器”固定宽度为375px。 But, in Chrome, the table is actually coming back with a width of 374.4px instead of 375. As a result, some of the background container div is seen to the right side of the table. 但是,在Chrome中,该表实际上返回的宽度为374.4px而不是375.因此,一些背景容器div可以看到表的右侧。 I have tried multiple combinations of table-collapse, box-sizing and table-display properties but can't seem to get this right. 我尝试了表崩溃,大小调整和表格显示属性的多种组合,但似乎无法做到这一点。 Any ideas? 有任何想法吗?

在此输入图像描述

Using Chrome: 58.0.3029.81 使用Chrome:58.0.3029.81

use this CSS: 使用这个CSS:

table-layout: fixed

<div style="display: table; table-layout:fixed; width: 375px; background: red;">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM