如何在 HTML 中使用 <tbody> 完全填充 <table> 100%?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6658792/
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
How do I completely fill a <table> 100% with <tbody> in HTML?
提问by Zaheer
I have some HTML that inject with Javascript into a web page. The final HTML I inject looks like:
我有一些用 Javascript 注入网页的 HTML。我注入的最终 HTML 如下所示:
<table style="border-width: 0px; margin 0px; width:100%; height: 100%; padding:0px;">
<tbody style="border-width: 0px; margin 0px; width:100%; height: 100%; padding:0px;">
For some odd reason when I examine tbody in Firebug, its size seems to be 4px smaller than the table. How do I get the to fill up ?
出于某种奇怪的原因,当我在 Firebug 中检查 tbody 时,它的大小似乎比表格小 4px。我怎样才能填满?
采纳答案by Ben Rowe
try adding the following css to your table:
尝试将以下 css 添加到您的表中:
border-collapse: collapse;
回答by ElonU Webdev
Try adding:
尝试添加:
border-collapse: collapse;
To your table
. Or try setting:
到您的table
. 或尝试设置:
display: block;
or
或者
display: table
on the tbody
element.
在tbody
元素上。