- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在构建看起来像 Slack 的简单 Web 应用程序,我在使页面占据全宽和全高方面遇到了问题。问题是它实际上结束了它的一半,其他时间花费了更长的时间,但左侧导航栏没有采用相同的尺寸,左侧导航的顶部 60% 显示的背景颜色与底部 40% 不同。
我已经包含了代码片段,我添加了几个参数“height:100%”和“height:100vh”并将它们添加到 *、html 和 body,但总是以某种方式变成不正确的东西。
* {
font-size: 16px;
margin: 0;
padding: 0;
}
.app {
display: flex;
flex-direction: row;
}
.leftNav {
border-right: 1px solid black;
width: 17%;
padding: 0px;
margin: 0;
background-color: lightslategray;
color: white;
}
.leftNav .title {
font-weight: 500;
padding-top: 10px;
padding-left: 10px;
}
.main {
display: flex;
flex-direction: column;
justify-content: flex-start;
width: 100%;
}
.main .messagesListContainer {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.main .messagesList {
padding: 5px;
}
.main .newMessage {
width: 100%;
}
.messagesList {
max-height: 450px;
overflow: auto;
}
.messagesEntry {
margin: 5px;
border-bottom: 1px solid black;
}
<div class="app">
<div class="leftNav">
<div class="title"> Channels </div>
<div>
Channel 1
</div>
<div>
Channel 2
</div>
</div>
<div class="main">
<div class="bar">
<Navbar>
Navbar goes here
</Navbar>
</div>
<div class="messagesListContainer">
<div class="messagesList">
What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</div>
<form>
<div>
<input placeholder='input' />
</div>
</form>
</div>
</div>
</div>
最佳答案
正如您所说,您正试图让 slack 像应用程序一样,所以我考虑了您顶部的 navbar
和底部的 input
将被修复.
这里我添加了
height: 100vh
到 .app
因为它是您应用程序的包装器,overflow: auto
到 .main .messagesListContainer
,这使得内部内容可以滚动。 这应该可以解决您的问题。
* {
font-size: 16px;
margin: 0;
padding: 0;
}
.app {
display: flex;
flex-direction: row;
height:100vh;
}
.leftNav {
border-right: 1px solid black;
width: 17%;
padding: 0px;
margin: 0;
background-color: lightslategray;
color: white;
}
.leftNav .title {
font-weight: 500;
padding-top: 10px;
padding-left: 10px;
}
.main {
display: flex;
flex-direction: column;
justify-content: flex-start;
width: 100%;
}
.main .messagesListContainer {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow: auto;
}
.main .messagesList {
padding: 5px;
}
.main .newMessage {
width: 100%;
}
.messagesList {
max-height: 450px;
overflow: auto;
}
.messagesEntry {
margin: 5px;
border-bottom: 1px solid black;
}
<div class="app">
<div class="leftNav">
<div class="title"> Channels </div>
<div>
Channel 1
</div>
<div>
Channel 2
</div>
</div>
<div class="main">
<div class="bar">
<Navbar>
Navbar goes here
</Navbar>
</div>
<div class="messagesListContainer">
<div class="messagesList">
What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The
point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem
Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Where
does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College
in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and
1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit
amet..", comes from a line in section 1.10.32.
</div>
<form>
<div>
<input placeholder='input' />
</div>
</form>
</div>
</div>
</div>
关于html - 为什么即使高度为 100% 和高度为 100vh,我也无法获得全长页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52881437/
我想制作一个sidenav,它可以是整个屏幕的长度,也可以是固定的,只滚动屏幕的右侧。不知何故,当右侧的高度大于钢筋的高度时,钢筋突然终止。请参见sidenav not full screen照片和代
这个问题在这里已经有了答案: How do I print a double value with full precision using cout? (17 个答案) 关闭 9 年前。 我有一个
在下面的代码中,我的第一个表行没有拉伸(stretch)到满,这令人沮丧。虽然第二张 table 很好并且可以按预期拉伸(stretch)。有人可以引用我的原因并帮助解决它吗? body {paddi
我正在尝试从中删除一个 URL: http://www.huffingtonpost.com/2013/08/01/edward-snowden-russia_n_3688225.html 为此: h
我有一个网络表单,我的客户希望用户能够打印出来。它可以很好地使用 CSS 进行一些样式设置,但是,我有几个 textaear 字段。如果用户键入的内容超过文本区域的高度,则该类型在打印时会被截断。 我
我想让一条水平线延伸到 Bootstrap 父元素指定的列宽。我正在使用 Bootstrap 4.1.1。代码如下。 Something here!
我是一名优秀的程序员,十分优秀!