- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试实现背景(绿色)为窗口高度的 100% 的布局,如果有覆盖层超出折叠,背景的高度应扩展以容纳更大的窗口高度。
我在 holder
中使用 Overlay
的原因是,如果这很重要,我正在使用 React 在 body 顶部显示覆盖。
html,
body {
height: 100%;
}
#holder {
background: green;
width: 100%;
min-height: 100%;
position: relative;
}
#logo {
height: 50px;
width: 100px;
display: block;
background: blue;
}
#overlay {
background: rgba(0, 0, 0, 0.5);
width: 100%;
margin-top: -50px;
min-height: 100%;
z-index: 10000;
position: absolute;
display: block;
}
#information {
height: 500px;
}
<div id='holder'>
<div id='logo'></div>
<div id='overlay'>
<div id='information'>
</div>
</div>
</div>
最佳答案
是这样的吗?
html, body{
height: 100%;
}
#holder{
background:green;
width:100%;
min-height:100%;
position:relative;
}
#logo{
height:50px;
width:100px;
display:block;
background:blue;
position: absolute;
top: 0;
z-index: 100;
}
#overlay{
background: rgba(0,0,0,0.5);
width: 100%;
min-height: 100%;
display: block;
top: 0;
position: relative;
z-index: 1000;
}
<div id='holder'>
<div id='logo'></div>
<div id='overlay'>
<div id='information'>
De standaard Lorem Ipsum passage, in gebruik sinds de 16e eeuw
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Sectie 1.10.32 van "de Finibus Bonorum et Malorum", geschreven door Cicero in 45 v.Chr.
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
1914 vertaling door H. Rackham
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
Sectie 1.10.33 van "de Finibus Bonorum et Malorum", geschreven door Cicero in 45 v.Chr.
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."
1914 vertaling door H. Rackham
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
</div>
</div>
</div>
关于html - body height 根据覆盖层的高度扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38180266/
这个问题在这里已经有了答案: How can I vertically align elements in a div? (28 个答案) Vertical Aligned Text and Im
我想做一个像 view0.height = view1.height + view2.height 这样的约束。当 view1.height 或 view2.height 改变时,view0.heig
有人可以解释为什么这个标记: 呈现大约 2x18 的 float div(在 Chrome/Firefox 中)而不是 2x2 div? 即使所有空格都被删除,图像似乎也遵循 font-
我的 HTML 页面上有一些可拉伸(stretch)的元素。 使用这个 CSS .stretchable-element { height: 25%; } 随着浏览器窗口高度的增加,可伸缩元素
我在“developer.android.com”上查看以缩小我的位图文件,但我发现了一件事我不明白。所以我很感激你能给我一点帮助。 这是一个 snippet来自 developer.android.
假设我们有以下设置: .container { background-color: red; width: 500px; min-height: 300px; } .child { b
我遇到了高度错误的问题 $(window).height(); 也有类似的问题 here 就我而言,当我尝试时 $(document).height(); 它似乎返回了正确的结果 窗口高度返回320
我正在尝试使用 javaFX (2.2) 开发桌面应用程序,但我遇到了一些困难,无法真正让它按照我希望的方式运行。作为该框架的新用户,我可能没有按应有的方式使用它... 我想要的是一种仪表板,在 Sc
就这么简单:) 我右边的列动态变化,由于左列的高度设置为 100%,我认为根据 Right_Column 的高度动态修改容器的高度会很好。有小费吗?谢谢:) 最佳答案 如果我正确理解了问题,你可以做这
我有一个 ScrollView(包含 NSTextEditor),其顶部、左侧和右侧约束相对于其容器(主窗口)正确设置为 0。 我无法使其高度为主容器的一半。有什么帮助吗? 最佳答案 如果我理解正确,
这个问题之前曾被问过(Infinite Scroll on Mobile browsers),但没有得到回应。 我正在尝试实现无限滚动。 检查文档是否在底部,导致更多加载的函数是: if ($(win
这个问题在这里已经有了答案: height:100% VS min-height:100% (4 个答案) 关闭 6 年前。
我在尝试解决这个问题时遇到了一些问题。我已经编写了一个 jquery 函数来检测用户何时点击页面底部并触发一个函数。现在,虽然这适用于最常见的屏幕尺寸,但当用户的屏幕太大以至于可以一次看到整个页面时,
如何获得与导航高度(填充)相同的导航高度 ...!? nav { width: 100%; } nav ul { text-align: center; background-
所以,实际上我可能完全想多了,应该放弃最小高度,但我目前有以下 HTML:
我正在阅读 Bootsrap3 文档。我发现这段页脚代码粘在屏幕底部。 html, body { height: 100%; } #wrap { min-height: 100%; height: a
我对容器 div 的高度有疑问。我想 它是 body 的 100%,但不起作用。我添加了 css body height=100% var d = document; $(d).ready(funct
我有一个三部分布局:页眉、内容和页脚。我非常熟悉绝对定位技术;当我希望内容 div 扩展到可用高度的 100% 时,我经常使用它。 在这种情况下,我的问题是我事先不知道页脚的高度,它是根据自己的内容动
在下面的代码中,我尝试实现无限滚动。我遇到的问题是“document.height”和“window.height”返回相同的值。有人可以帮我解决我哪里出错了吗?
我有一个页面布局,其中两个 div 在一行中彼此相邻对齐。一列包含可变长度的文本,第二列包含图像。 标记基本上如下: texttext 我的
我是一名优秀的程序员,十分优秀!