目标:消除两行图像之间的白色间隙:
复制案例:https://jsfiddle.net/kromato4/5cyLvnut/
差距不会出现在 html 下,但当我切换到 xhtml 时突然出现(而这将进入的 epub 需要 xhtml)。
这是 html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>divs to the rescue?</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="grid">
<div class="gridrow">
<div ><img src="https://i.imgur.com/pvh1qBn.jpg"/></div>
<div ><img src="https://i.imgur.com/Mmnz4YT.gif"/></div>
<div ><img src="https://i.imgur.com/3nAJxUE.gif"/></div>
</div>
<div class="gridrow">
<div><img src="https://i.imgur.com/C8mn56T.gif" /></div>
<div><img src="https://i.imgur.com/Tic5I5b.gif" /></div>
</div>
</div>
</body>
</html>
和最小的 CSS:
.grid {
display: table;
width: 585px;
height: 580px;
}
.gridrow {
display: table;
}
.gridrow > div {
display: table-cell;
我在 divs 上设置高度无济于事。顶行图像都是 255 像素高,但包含图像的 div 似乎多了 4 像素高。还尝试使用包含行和列的表,但显示了同样的问题。任何帮助表示赞赏,因为当图像都是来自同一部漫画的面板时,这种差距会让人分心。
最佳答案
在图片标签上定义显示 block ,见附件代码
.gridrow > div img {
display: block;
}
关于html - webkit下xhtml设置div为特定高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59540073/