css可以放3种地方
一般写在css里,在head之前用link调用
<link href="home.css" rel="stylesheet" type="text/css" />
也可以写在文件里,在head之前写一个style标签
<style type="text/css">
body, h1, h2 { font-family: "Trebuchet MS", Trebuchet, Verdana, Helvetica, Arial, sans-serif; }
h1 { margin: 1em 0 1.5em; font-size: 18px; }
h2 { margin: 2em 0 1.5em; font-size: 16px; }
p { margin: 0; }
code { font-family: "Courier New", Courier, monospace; }
</style>
最直接的写在标签中,注意每一项之间要加分号。
<table style="margin:auto;border-spacing:50px;width:100%;vertical-align:middle;background-color:#666666">
border-spacing可以调整单元格之间的间距
vertical-align有些诡异,等会会转载一篇文章。
table这个标签,很神奇,几乎可以衍变成各种复杂布局,不过单元格宽度是不可以设置固定值的,一般确定table的宽度,以及单元格间距,再使其居中即可。
<style type="text/css">
td{
border:solid;
margin:5px;
}
tr{
height:100px;
padding:10px;
}
</style>
<div style="margin:auto;width:1200px;">
<table style="margin:auto;border-spacing:50px;width:100%;vertical-align:middle;background-color:#666666">
<tr>
<td>
td1
</td>
</tr>
<tr>
<td>
td1
</td>
</tr>
</table>
</div>