[英]HTML5 Table Spacing Issues
I'm trying to get all of these images to line up in a table. 我正在尝试将所有这些图像排列在一张桌子中。 For some reason it is adding extra space at the bottom of the cells.
由于某种原因,它在单元的底部增加了额外的空间。 I've tried all of the different solutions that is suppose to fix this spacing issues.
我尝试了所有解决此间距问题的不同解决方案。
What it's supposed to look like 它应该看起来像什么
Here's a look at my HTML5 code as well: 这也是我的HTML5代码:
<!DOCTYPE html> <html>
<head>
<title></title>
<meta charset = "utf 8">
<style>
table{
border-collapse : collapse;
border-spacing : 0;
border:0;
}
tr,td{
border-collapse:collapse;
padding : 0;
border : 0;}
</style>
</head>
<body>
<table>
<tr>
<td><img src="tableImages\ul.gif" alt ="1,1"></td>
<td colspan = "2"><img src ="tableImages\top.gif" alt = "1,2"></td>
<td><img src="tableImages\ur.gif"alt="2,2"></td>
</tr>
<tr>
<td rowspan = "2"><img src="tableImages\left.gif"alt="2,1"></td>
<td><img src="tableImages\1.gif"alt="2,1"></td>
<td><img src="tableImages\2.gif"alt="2,1"></td>
<td rowspan = "2"><img src="tableImages\right.gif"alt="2,1"></td>
</tr>
<tr>
<td><img src="tableImages\3.gif"alt="2,1"></td>
<td><img src="tableImages\4.gif"alt="2,1"></td>
</tr>
<tr>
<td><img src="tableImages\ll.gif" alt ="1,1"></td>
<td colspan = "2"><img src ="tableImages\bottom.gif" alt = "1,2"></td>
<td><img src="tableImages\lr.gif"alt="2,2"></td>
</tr>
</table>
</body> </html>
I've come to the realization that the problem lies within HTML5, because if I remove <!DOCTYPE html>
(meaning that the browser won't read it in 5) I don't have this problem. 我已经意识到问题出在HTML5之内,因为如果删除
<!DOCTYPE html>
(这意味着浏览器不会在5中读取它),我就不会遇到这个问题。
If anyone could help me, Thank you very much! 如果有人可以帮助我,非常感谢!
So after some fiddling around to reproduce the problem, i found what is wrong ( here a JSFiddle of the problem ). 因此,在摆弄一些问题以重现问题之后,我发现了问题所在( 这里是问题的JSFiddle )。
an image is by default displayed as a inline-block
, this means that the height is calculated according to the font-size. 默认情况下,图像显示为行
inline-block
,这意味着高度是根据字体大小计算的。 It is expecting a font, so it has a font-size
by default ( see this answer for more info ). 它需要字体,因此默认情况下具有
font-size
( 有关更多信息,请参见此答案 )。 There 2 ways of fixing this. 有2种解决方法。
Simply change the property display
to block
只需将属性
display
更改为block
img {
display: block;
}
Simply change the font-size
to 0
只需将
font-size
更改为0
td {
font-size: 0;
}
Note that i used the first <td>
only as example, this should work with all of them 请注意,我仅以第一个
<td>
为例,这应该适用于所有这些
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.