Bootstrap 5 是一个流行的前端框架,用于快速构建响应式网页设计。要创建一个全屏两列的应用程序,其中内容可滚动,你可以使用 Bootstrap 的网格系统和一些自定义 CSS。以下是一个基本的示例,展示了如何实现这一目标:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap 5 Fullscreen Two Column Layout</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet">
<style>
html, body {
height: 100%;
margin: 0;
}
.container-fluid {
height: 100%;
}
.row {
height: 100%;
}
.col {
overflow-y: auto;
padding: 1rem;
}
</style>
</head>
<body>
<div class="container-fluid d-flex flex-column">
<header class="bg-primary text-white p-3">
Header
</header>
<div class="row flex-grow-1">
<div class="col-md-6 bg-light">
<!-- Content for the first column -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...</p>
<!-- Add more content to enable scrolling -->
</div>
<div class="col-md-6 bg-secondary text-white">
<!-- Content for the second column -->
<p>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ...</p>
<!-- Add more content to enable scrolling -->
</div>
</div>
<footer class="bg-dark text-white p-3">
Footer
</footer>
</div>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>
.col
类设置了 overflow-y: auto;
。通过上述方法,你可以创建一个简洁且功能齐全的全屏两列布局,适用于多种网页设计需求。
领取专属 10元无门槛券
手把手带您无忧上云