将div设置为webkit下xhtml中的特定高度

问题描述 投票:0回答:2

目标:去除两行图像之间的白色间隙:https://i.stack.imgur.com/i5HTI.png

重复情况:https://jsfiddle.net/kromato4/5cyLvnut/

该间隙不会出现在html下,但是当我切换到xhtml时会出现(并且进入epub的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;

我已经在div上设置了高度,但是毫无用处。最上面一排图像的高度均为255像素,但包含这些图像的div似乎又高了4像素。还尝试使用带有行和列的表,但显示了相同的问题。当图像是同一漫画的所有面板时,此间隙会分散您的注意力,因此不胜感激。

html css xhtml
2个回答
0
投票

在图像标签上定义显示块,请参见附加代码

.gridrow > div img { 
  display: block;
}

0
投票

欢迎来到SO

将图像设置为显示table

.gridrow img {
    display: table;
}
© www.soinside.com 2019 - 2024. All rights reserved.