HTML table Width = "100%" 仍然不适合 ASP.Net 中的窗口大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20547776/
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:27:09  来源:igfitidea点击:

HTML table Width = "100%" still didn't fit to window size in ASP.Net

htmlasp.netcss

提问by Kpt.Khaos

I have a html table for displaying data. I have the typical width="100%"; but it did not work. Here is what my page looks like and my CSS/HTML styling. How can I fix it to auto fit the screen?

我有一个用于显示数据的 html 表。我有典型的 width="100%"; 但它没有用。这是我的页面和我的 CSS/HTML 样式。如何修复它以自动适应屏幕?

Code:

代码:

<table style="border: medium solid #FFFFFF; background-color: #000000; position: fixed;"
             border="3" width="100%";>

回答by SW4

Make sure your bodyelement has paddingand marginset to 0

确保您的body元素具有paddingmargin设置为0

Without setting thisvs when this is set

不设置此项设置此项

html, body{
    height:100%;
    width:100%;
    padding:0;
    margin:0;
}

回答by frogatto

Add this CSS:

添加这个CSS:

body {
    margin: 0
}

Because the default margin for bodyelement in not 0

因为body元素的默认边距不是0

回答by Java Student

add these lines in your style

以您的风格添加这些线条

*{margin:0; padding:0;} 

回答by DreamTeK

You have 100% width plus a border. This is greater than 100%.

您有 100% 宽度和边框。这大于 100%。

HTML

HTML

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

CSS

CSS

.tbl{
    position:fixed;
    width:100%;
    border:3px solid #fff;
    background:#000;
    box-sizing:border-box; /* causes item size to include border and padding */
    -moz-box-sizing:border-box; /*for browser compatibility*/
}