html - 两个 div(一个有绝对高度,另一个有滚动条)

标签 html css

我想要的网站风格如下: enter image description here

图中显示了“OTHER DIV”和“MOTHER DIV”当前的样式。我如何设置其他 div 的样式,例如 .div_top.div_bottom 以便在需要时仅在 .div_bottom 中获得滚动条?

此外,我希望 .div_bottom 中的滚动条在 .div_top 变大(高度)时自行调整: enter image description here

我认为.div_top 的高度必须是 auto 因为.div_top里面有一个div可以使用 jQuery 隐藏和显示。

@JonasLoerken

enter image description here

这是您的第二个结果。我该如何解决这个问题?

最佳答案

html {
  box-sizing: border-box;  
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

html,
body {
  height: 100%;
  padding: 0;
  margin: 0;
}

body {
  display: flex;
  height: 100%;
  flex-flow: row nowrap;
  overflow: hidden;
}


.Aside {
  width: 200px;
  background-color: #333;
}

.Main {
  flex: 1;
  display: flex;
  flex-flow: column nowrap;
}
.Main__header {
  height: 40px;
  min-height: 40px;
  background-color: #777;
}
.Main__content {
  overflow-y: auto;
}
<aside class="Aside">#Aside</aside>
<main class="Main">
  <header class="Main__header">#Header</header>
  <section class="Main__content">
    <h1 class="Main__content-header">#Scroll</h1>
    <p class="Main__content-text">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. 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. 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.</p>
  </section>
</main>

关于html - 两个 div(一个有绝对高度,另一个有滚动条),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32479771/

相关文章:

javascript - @font-face 套件预加载器

javascript - Masonry 具有异步图片加载功能

html - 表格中未显示边框底部宽度

css 未在 Rails 生产环境中加载

css - 与内联元素相关的绝对位置

css - 使用 Angular ngAnimateSwap 指令的简单向前和向后 CSS 动画

html - 如何在 CSS 中垂直居中内联元素

php - DIV标签在php中创建新行

html - 标签覆盖链接操作

html - 如何使用 HTML 在 div 中制作带有图像的网格?