1
我试图将此页眉置于页面中间。不知道为什么margin-left:auto
和margin-right:auto
不起作用。它不会为表格注册align:center
。该表只是一个标题。这是我对css和table的代码。页面HTML中的中心表
<style>
table {
margin-top: 2em;
margin-left: auto;
margin-right: auto;
}
table th {
background: linear-gradient(to bottom right, #6688FF, #AACCFF);
height: 4em;
text-align: center;
text-transform: capitalize;
color:white;
border:#ccc 1px solid;
}
table tr {
text-align: center;
}
table thead {
position:fixed;
}
</style>
<table class="head">
<%--header --%>
<thead>
<tr>
<th>one</th>
<th>two</th>
<th>three</th>
</tr>
</thead>
<%--body --%>
<tbody>
</tbody>
</table>
我想作一个单独的表头孤单,因为我不想被固定在首页的页眉滚动浏览数据表。你的方法是有效的,但是当窗口大小调整时,有没有将它移动?我使用的是asp.net,所以数据表只是'HorizontalAlign =“Center”' – mysticalstick
因此,这种方法的美丽(你应该能够通过点击全屏按钮来测试片段),它应该总是水平居中这种方法,甚至在调整大小。因此,除非您在较小的屏幕上进行其他设计更改,否则无需担心响应式更新。 –