【发布时间】:2018-09-02 20:58:33
【问题描述】:
我正在使用 bootstrap 4 构建一个响应式页面,该页面有一个标题/标题部分,其中包含客户徽标的图像、他们的名称和导航栏。所有这些元素都是响应式的,即图像根据屏幕尺寸缩小,导航栏在小屏幕上最小化。
现在我想让身体也以一种响应的方式。即:用内容填充屏幕的剩余高度,必要时使用滚动条显示所有内容。
但由于某种原因,我无法弄清楚如何将页面的其余部分跨越整个高度。它要么在某些较大的屏幕上太大,但它非常适合移动设备,或者它非常适合大屏幕,但只有移动设备上应有的高度的一半。
页面大致是这样构建的:
<!DOCTYPE html>
<html lang="de" style="height:100%">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Client Name</title>
</head>
<body class="main" style="height:100%">
<div class="container">
<div class="text-center">
<!-- Client image goes here -->
<h1 style="display:inline;margin-left:0.6em;color:#8b7d7b">Client Name</h1>
</div>
</div>
<nav class="navbar navbar-expand-lg navbar-light" style="background-color:#e0eee0">
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#mainnavbar" aria-controls="mainnavbar" aria-expanded="false" aria-label="Toggle Navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="mainnavbar" class="navbar-collapse collapse justify-content-md-center">
<ul class="navbar-nav">
<li class="nav-item nav-link active">Page A</li>
</ul>
</div>
</nav>
<div class="container" style="height:70vh">
<div class="row" style="height:100%">
<!-- Main body of page -->
<div class="col-sm-1 col-md-9" style="height:100%">
<p class="col-scrol">
<!-- Main part of the page. Content should have full height and scroll vertically if necessary -->
</p>
</div>
<!-- Comment section (scrolling) -->
<div class="d-none d-md-block col-md-3 comment-section">
<!-- Comment section at the left hand side of the page -->
</div>
</div>
</div>
</body>
</html>
我创建了一个实际显示整个页面的 plunkr:
https://plnkr.co/edit/GQHoephQyx3hoejgkT4k?p=preview
在 bootstrap 4.0 中,根据需要显示页面的正确方法是什么,即使用图像根据屏幕尺寸缩小/增长时剩余的全部高度?
编辑澄清:
内容本身应该有一个滚动条,而不是整个页面。 IE。带有图像和菜单栏的标题应始终保持可见,而随后出现的内容应具有滚动条(如有必要)。
【问题讨论】:
-
请回答:如果要使用Bootstrap 4,为什么代码引用Bootstrap 3?
-
你是对的。对不起。在此处和 Plunkr 示例中修复了该问题。我下载了文件以在本地包含它们,因此我不得不将包含的内容替换为在线包含的内容,并且我使用了错误的 url。问题的实际问题仍然适用。
标签: html css twitter-bootstrap bootstrap-4