html - Bootstrap 布局可滚动 div
问题描述
我做了一个小提琴来展示我尝试过的东西,我想要一个没有滚动条的页面,并且当它们溢出时让 col left 和 col right div 得到一个滚动条。
有人可以告诉我我错过了什么吗?或者,如果您知道使用引导程序的更清洁的解决方案,请告诉我。
当小提琴到期时,我也将 html 粘贴到此处以供将来参考。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<div class="container-fluid" id="my-container">
<div class="row" id="my-full-row">
<div class="" id="my-menu-col">
M
</div>
<div class="col">
<div class="row" id="my-title-row">
Title row
</div>
<div class="row" id="my-row">
<div class="col-sm-2" id="my-col-left">
col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>
col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>
col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>col left<br/>
</div>
<div class="col-sm-10" id="my-col-right">
col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>
col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>
col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>col right<br/>
</div>
</div>
</div>
</div>
</div>
和CSS
html, body {
height: 100%;
margin: 0;
}
.row {
margin: 0px;
}
.col {
padding: 0px;
}
#my-container {
height: 100%;
padding: 0px;
}
#my-full-row {
height: 100%;
}
#my-menu-col {
height: 100%;
width: 50px;
background-color: purple;
}
#my-title-row {
background-color: red;
height: 50px;
}
#my-row {
background-color: blue;
height: 100%;
}
#my-col-left {
background-color: green;
overflow-y: scroll;
}
#my-col-right {
background-color: yellow;
overflow-y: scroll;
}
#u { background-color: #337ab7; }
解决方案
你有很多重复的 CSS,所以我建议你清理一下。如果我了解您想要什么,当视口足够高以容纳内容时,删除height: 100%;
from会阻止它滚动。#my-row
我也添加了这个:
#my-col-left, #my-col-right {
height: 100%;
}
推荐阅读
- c# - 为什么 Ctrl+Shift+D0 不会触发 KeyDown ...我该怎么办?
- javascript - 具有高于 Number.MAX_SAFE_INTEGER 的值有什么意义?
- entity-framework - 使用不在 DbContext 中的子类查找
- conda - Conda `update --all` 防止降级
- r - 在 R 中下载 tidycensus 库时出错
- shopify - 在 Shopify 中使用 Porto 主题 3.6.3 如何关闭特定产品的添加到购物车?
- sql - SQL - 计算列
- css - 阻止固定叠加层下方的元素使用 Tailwind 滚动
- node.js - Nodejs 应用程序控制面板有哪些解决方案?
- linux - 无法在 Linux 上安装 GitHub 操作运行程序