没有空格的 HTML 表格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13709632/
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
HTML Table with No Space
提问by ?smet Alkan
I have the following CSS code:
我有以下 CSS 代码:
tr.uprightTr
{
padding: 0px;
margin: 0px;
height: 10px;
border: none;
border-spacing: 0px;
}
td.uprightTd
{
padding: 0px;
margin: 0px;
height: 10px;
border: none;
border-spacing: 0px;
}
table.uprightTbl
{
padding: 0px;
margin: 0px;
border: none;
border-collapse: collapse;
border-spacing: 0px;
}
And the following HTML:
以及以下 HTML:
<table class="uprightTbl" cellpadding="0" cellspacing="0">
<tr class="uprightTr">
<td class="uprightTd"><input type="checkbox" /></td>
...
No matter what I tried, it keeps some space between elements. Any ideas on what I can try or might be doing wrong?
无论我尝试什么,它都会在元素之间保留一些空间。关于我可以尝试或可能做错的任何想法?
P.S: I also checked out the element on Chrome, element reaches the related css lines successfully.
PS:我也在Chrome上查看了元素,元素成功到达了相关的css行。
回答by Ulflander
Did you try to add a CSS rule for all elements such as:
您是否尝试为所有元素添加 CSS 规则,例如:
.uprightTbl * {
border: none;
border-collapse: collapse;
padding: 0;
margin: 0;
}
It may solve your problem.
它可能会解决您的问题。
回答by prajan55
Add the below css code:
添加以下css代码:
input[type=checkbox] { margin:0 }
By default, the browser set some margin around.
默认情况下,浏览器会设置一些边距。
Hope this helps..
希望这可以帮助..
回答by Rups
Apply below styles:
应用以下样式:
border-spacing:0;
border-collapse:collapse;
This query is already present: Set cellpadding and cellspacing in CSS?
此查询已存在:在 CSS 中设置单元格填充和单元格间距?
回答by Brandon Trecki
Check for any display:inline-block... and change to display:block. Inline-block adds 3-4px of space after the element...
检查任何 display:inline-block... 并更改为 display:block。Inline-block 在元素后添加 3-4px 的空间...
If you are using any images make sure they are displayed as block.
如果您使用任何图像,请确保它们显示为块。