Html 设置网页宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2486365/
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
Setting up web page width
提问by RKh
I am new to web-design. I want to set the page-width so that it appears well in a 800x600 resolution screen. I normally use Tables but I read somewhere that excessive use of Tables slows the performance of the website. What other thing I can use and how to set the width?
我是网页设计的新手。我想设置页面宽度,使其在 800x600 分辨率的屏幕中显示良好。我通常使用表格,但我在某处读到过度使用表格会降低网站的性能。我可以使用什么其他东西以及如何设置宽度?
采纳答案by Faruz
Yes, Tables are so 1995....
是的,表格是如此 1995 年......
Now you're supposed to use DIVs and SPANs.
现在您应该使用 DIV 和 SPAN。
http://www.smashingmagazine.com/2009/04/08/from-table-hell-to-div-hell/
http://www.smashingmagazine.com/2009/04/08/from-table-hell-to-div-hell/
also, w3schools are the normal resource for html starters
此外,w3schools 是 html starters 的正常资源
but, why bother, you can use an already made layout from websites like: http://www.freelayouts.com/websites/html-templates
但是,为什么要麻烦,您可以使用来自以下网站的已经制作的布局:http: //www.freelayouts.com/websites/html-templates
回答by david
Usings DIVs rather than tables would look like this
使用 DIV 而不是表格看起来像这样
<div style="width:800px">
<!-- your content here -->
</div>
This produces on column with the width of 800 pixels. Keep in mind that you normally may put your style definitions in an externals *.css file. In reality you will have some nested DIVs too which hold e.g. your main menu and content e.g.
这将生成宽度为 800 像素的列。请记住,您通常可以将样式定义放在 externals *.css 文件中。实际上,您也会有一些嵌套的 DIV 来保存例如您的主菜单和内容,例如
<div id="wrapper">
<div id="topMenu">
<!-- menu items -->
</div>
<div id="content">
<!-- content -->
</div>
</div>
Here I have used IDs for specific items which can be addressed uniquely. It's easy to assign styles to them via CSS:
在这里,我使用了可以唯一寻址的特定项目的 ID。通过 CSS 为它们分配样式很容易:
#wrapper {
width:800px;
}
#topMenu {
width:800px;
height:200px;
}
Sooner or later you will stumble upon the term "floating divs" which is another big topic.
迟早你会偶然发现“浮动 div”这个词,这是另一个大话题。