减少 HTML 表格行高

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20251656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:15:51  来源:igfitidea点击:

Reducing HTML Table Row Height

htmlcss

提问by logan

I have table with few rows. I want 1st and 3rd row height to be set to 1 px and the 2nd row to normal height. But my code is not working.

我有几行的表。我希望第 1 行和第 3 行高度设置为 1 像素,第 2 行设置为正常高度。但是我的代码不起作用。

enter image description hereHTML CODE goes below

在此处输入图片说明HTML 代码如下

<table border="0">
   <tr style="height:2px;" >
    <td width="10"><hr></td>

  </tr>
<tr style="height:20px;" >
    <td width="10">Hello</td>

  </tr>
  <tr style="height:20px;" >
    <td width="10"><hr></td>

  </tr>
</table>

Could anyone please tell me how to do it ?

谁能告诉我怎么做?

Note: I dont want borders to be used because i Want for certain rows i may or may not need the horizontal line inside the rows.

注意:我不想使用边框,因为我想要某些行,我可能需要也可能不需要行内的水平线。

回答by forumma

Add style="padding:0px; margin:0px;"to your hrand change the heightof your third trto 2px

添加 style="padding:0px; margin:0px;"到您的hr并将height您的第三个更改tr2px

You will have :

你将会有 :

<table border="0">
   <tr style="height:2px;" >
    <td width="10px"><hr style="padding:0px; margin:0px;"></td>
  </tr>
<tr style="height:20px;" >
    <td width="10px">Hello</td>
  </tr>
  <tr style="height:2px;" >
    <td width="10px"><hr style="padding:0px; margin:0px;"></td>
  </tr>
</table>