表格中图像之间出现空白

发布于 2024-11-28 14:29:48 字数 740 浏览 1 评论 0原文

我有以下 HTML:

<table width="700" align="center" style="border:0">
    <tr style="border:0"> <td> <img src="images\1.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\2.png" /> </td> </tr>
    <tr style="border:0"> <td> <img src="images\3.png" /></td> </tr>
    <tr style="border:0"> <td> <img src="images\4.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\5.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\6.png" /> </td></tr>
</table>

问题是图像之间出现空白。我该如何删除它?

I have the following HTML:

<table width="700" align="center" style="border:0">
    <tr style="border:0"> <td> <img src="images\1.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\2.png" /> </td> </tr>
    <tr style="border:0"> <td> <img src="images\3.png" /></td> </tr>
    <tr style="border:0"> <td> <img src="images\4.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\5.png" /> </td></tr>
    <tr style="border:0"> <td> <img src="images\6.png" /> </td></tr>
</table>

The problem is that white space is appearing between the images. How do I remove it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

神经大条 2024-12-05 14:29:49
<table width="700" align="center" border="0" cellpadding="0" cellspacing="0">
        <tr><td> <img src="images\1.png" /></td></tr>
        <tr><td> <img src="images\2.png" /></td></tr>
        <tr><td> <img src="images\3.png" /></td></tr>
        <tr><td> <img src="images\4.png" /></td></tr>
        <tr><td> <img src="images\5.png" /></td></tr>
        <tr><td> <img src="images\6.png" /></td></tr>
    </table>
<table width="700" align="center" border="0" cellpadding="0" cellspacing="0">
        <tr><td> <img src="images\1.png" /></td></tr>
        <tr><td> <img src="images\2.png" /></td></tr>
        <tr><td> <img src="images\3.png" /></td></tr>
        <tr><td> <img src="images\4.png" /></td></tr>
        <tr><td> <img src="images\5.png" /></td></tr>
        <tr><td> <img src="images\6.png" /></td></tr>
    </table>
晚风撩人 2024-12-05 14:29:49

首先将 cellspacing="0" cellpadding="0" 添加到表格元素

  <table width="700" align="center" style="border:0" cellspacing="0" cellpadding="0">

并删除 td 和 img 标签之间的空格

first add cellspacing="0" cellpadding="0" to your table element

  <table width="700" align="center" style="border:0" cellspacing="0" cellpadding="0">

and remove spaces between td and img tags

怂人 2024-12-05 14:29:49

您可以尝试不使用表格,这样您就可以...

<img src="images/1.png" />
...
<img src="images/6.png />

并使用一些CSS使它们成为没有边距/填充的块元素

,或者您可以像这样在表格上使用CSS...

<style>
    table { border-collapse: collapse; }
</style>

您还需要添加一个您的表的几个属性

<table .... cellspacing="0" cellpadding="0" ...>

都试图摆脱表上的 padding.margin 。

但 IMO 对于你想要做的事情,使用 css 直接使用 标签路由会更好。

You could try not using a table, so you'd have ...

<img src="images/1.png" />
...
<img src="images/6.png />

and use some css to make them block elements with no margin/padding

or you could use css on your table like this ...

<style>
    table { border-collapse: collapse; }
</style>

you would also need to add a couple of attributes to your table

<table .... cellspacing="0" cellpadding="0" ...>

all trying to get rid of padding.margin on your table.

But IMO for what you're trying to do, going the straight <img /> tag route with css would be better.

失去的东西太少 2024-12-05 14:29:49
<table cellspacing="0"> 

应该解决它:)

<table cellspacing="0"> 

should solve it :)

橪书 2024-12-05 14:29:49

更改 ,将cellspacing和cellpadding设置为0,然后检查

change <td> <img src="images\1.png" /> </td></tr> to <td><img src="images\1.png" /></td></tr>, set cellspacing and cellpadding to 0, and check

唯憾梦倾城 2024-12-05 14:29:49

添加到您的风格

border-spacing:0px; 

Add to your style

border-spacing:0px; 
你又不是我 2024-12-05 14:29:49

对于 Transitional Doctype,互联网上大多数建议的解决方案都有效。

但对于 Strict Doctype,以下内容将删除 中两个图像之间的白线:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

<title>Test</title>

</head>    
<body>

<table cellspacing="0" cellpadding="0">

<tr><td><img style="display:block;" src="../images/test_blue.jpg"></td></tr>

<tr><td><img style="display:block;" src="../images/test_green.jpg"></td></tr>

</table>

</body>
</html>

想要在此处发布屏幕截图,但声誉不足,无法这样做。

For Transitional Doctype, most of the suggested solutions in the internet works.

But for Strict Doctype, the following will remove the white line between two images in <TD>:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

<title>Test</title>

</head>    
<body>

<table cellspacing="0" cellpadding="0">

<tr><td><img style="display:block;" src="../images/test_blue.jpg"></td></tr>

<tr><td><img style="display:block;" src="../images/test_green.jpg"></td></tr>

</table>

</body>
</html>

Want to post the screenshot here but insufficient reputation post to do so.

淡笑忘祈一世凡恋 2024-12-05 14:29:49

删除作为博客一部分的表格中图像之间出现的空白

对于那些在博客上遇到此问题后来到这里的人。我遇到了同样的问题。然而,我的桌子是博客上的博客的一部分。我在表格的一个单元格中都有图像。我尝试了单元格间距、单元格填充和许多其他属性和参数,但没有任何效果。对于博客,在博客模板中进行了这些更改:

  • 在“.post-body img”下,“padding: 10px”值更改为“padding: 0px”[这删除了图像之间的垂直空间]

  • 在“.post-body”值下“行高:1.4;”更改为“行高:0;” [这删除了表格行之间的空间]

此处有更详细的答案:

http ://xomisse.com/blog/tutorial-remove-spaces- Between-images-in-blogger/

Removing white spaces appearing between images in a table which is part of the blog:

For those who came here after facing this problem on blogs. I faced same problem. However my table was part of a blog on blogger. I had images each in a cell of the table. I tried cellspacing, cellpadding and many other attributes and parameters but nothing worked. In case of blog, in the blog template these changes were made:

  • Under ".post-body img" value of "padding: 10px" changed to "padding: 0px" [This removed verticle space between images]

  • Under ".post-body" value of "line-height: 1.4;" changed to "line-height: 0;" [This removed space between table rows]

More detailed answer here:

http://xomisse.com/blog/tutorial-remove-spaces-between-images-in-blogger/

残疾 2024-12-05 14:29:49

您如何归档数据?想到服务器了吗?

在某些文本编辑器中,您可以使用正则表达式进行搜索。然后您可以执行以下操作:

搜索:

<td>(\s*)(.*?)(\s*)</td>

替换:

<td>$2</td>

搜索:

<td>[WHITE SPACE IF ANY]STRING[WHITE SPACE IF ANY]</td>

并将其替换为:

<td>STRING</td>

How are you archiving your data? Thought the server?

In some text editors you can make searches with regular expression. Then you can do this:

Search:

<td>(\s*)(.*?)(\s*)</td>

Replace:

<td>$2</td>

Searches for:

<td>[WHITE SPACE IF ANY]STRING[WHITE SPACE IF ANY]</td>

And replaces it with:

<td>STRING</td>
醉城メ夜风 2024-12-05 14:29:49

尝试:

display:inline-block;
vertical-align:top;

Try:

display:inline-block;
vertical-align:top;
一身骄傲 2024-12-05 14:29:49

此外,某些移动浏览器可能会在没有宽度和高度属性的图像之间创建空白。将图像尺寸设置为 td 并将图像 w 100% h 100% 设置为。

<table width="700" align="center" border="0" cellpadding="0" cellspacing="0">
    <tr><td width="100" height="100"> <img src="images\1.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\2.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\3.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\4.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\5.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\6.png" /></td></tr>
</table>

<style>
    table td img { width:100%; height:100%; }
</style>

Also some mobile browsers may create white spaces between images without width and height attribute. Set your images sizes to td and set your images w 100% h 100%.

<table width="700" align="center" border="0" cellpadding="0" cellspacing="0">
    <tr><td width="100" height="100"> <img src="images\1.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\2.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\3.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\4.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\5.png" /></td></tr>
    <tr><td width="100" height="100"> <img src="images\6.png" /></td></tr>
</table>

<style>
    table td img { width:100%; height:100%; }
</style>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文