1 回答
TA贡献1828条经验 获得超4个赞
我做了一些编辑,现在你的导航栏工作正常:
如果你想使用绝对定位,只需添加position:relative; 导航栏和更高的 **z-index*
var table = document.getElementById("table");
var w = window.innerWidth;
var h = window.innerHeight;
var wsquare = 30, hsquare = 30;
var m = w / wsquare, n = h / hsquare;
for(var i = 0; i < n - 1; i++) {
var row = table.insertRow(i);
for(var j = 0; j < m - 1; j++) {
var cell1 = row.insertCell(j);
}
}
nav {
position:relative;
z-index: 2;
}
table {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
th, table, td{
border: 1px solid black;
border-collapse: collapse;
}
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>PathFinding</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Name</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
</div>
</nav>
<table id= "table">
</table>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报