所以,我使用HTML div
和table
元素创建了一个导航栏。
.menu {
background-color: black;
color: white;
font-family: Segoe UI;
}
<div class="menu">
<table border="0" cellspacing="10">
<tr>
<td>Home</td>
<td>About</td>
<td>Login</td>
</tr>
</table>
</div>
当然,它现在还没有完成,请不要问为什么我没有使用无序列表<ul>
而不是表。
所以,我想在屏幕顶部修复此菜单。在div之前没有留下空格。什么是CSS代码?
body {
margin: 0;
}
.menu {
background-color: black;
color: white;
font-family: Segoe UI;
}
<div class="menu">
<table border="0" cellspacing="10">
<tr>
<td>Home</td>
<td>About</td>
<td>Login</td>
</table>
</div>
你可以使用css属性position : fixed;
和width : 100%
在所有屏幕上显示它
尝试遵循CSS代码:
.menu {
background-color: black;
color: white;
font-family: Segoe UI;
position: fixed;
top: 0;
left: 0;
width: 100%;
}