如何在中创建表格div(使用剩余屏幕高度)滚动而不滚动整个页面?HTML + CSS:在屏幕内部滚动屏幕高度
我知道如何使它在div内滚动通过包装它像这样
<div style="overflow: auto; height: 300px;">
<table>...</table>
</div>
,但我怎样才能使div的高度使用所有剩余屏幕的高度?
编辑:这是到目前为止我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Table</title>
<link rel=stylesheet href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="col-md-12">
<div class="panel panel-default">
<!-- Header -->
<div class="panel-heading">Panel Heading<button class="pull-right" onclick="myFunction();">
<span class="glyphicon glyphicon-filter"></span>
</button>
</div>
<div class="panel-body row" id="filter" style="display: none; padding-top: 0;">
<div class="col-md-6">
<div class="col-sm-6 column" style="height: auto; margin-top: 1em">
<!-- filter selector -->
</div>
</div>
</div>
<!-- Table -->
<div class="panel-body" style="overflow: auto; height: 300px;">
<table class="table">
...
</table>
</div>
</div>
</div>
<script>
function myFunction() {
var x = document.getElementById('filter');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
</script>
</body>
</html>
如果您分享一些代码以便其他成员不必猜测发生了什么,您将获得帮助。谢谢 –
你以前用过'height:100vh'吗?使用它可能会帮助你 – Maher