CSS block 布局全屏

标签 css layout

想做一个大致像这样的屏幕布局:

enter image description here

整个浏览器窗口应该填充仅有的两个“已知”高度元素,即顶部、左侧和底部、左侧的白色 block (对于两个标签,因此已知将与字体相关)。其他所有内容都应随浏览器窗口缩放,即左侧栏宽 15%,右侧栏宽 85%,等等。

作为一名 C++ 开发人员,我的直觉是处理 Javascript 中的事件和针对 DOM 的代码,但我觉得这对于 CSS 来说相对微不足道。

谁能帮帮我?

最佳答案

我试图快速重现:

* {
  box-sizing: border-box;
}
html,
body,
.wrapper {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
.left,
.right {
  float: left;
}
.left {
  position: relative;
  width: 15%;
  height: 100%;
}
.left .label-top,
.left .label-bottom {
  position: absolute;
  width: 100%;
  background-color: #fff;
}
.left .label-top {
  top: 0;
  left: 0;
}
.left .label-bottom {
  bottom: 0;
  left: 0;
}
.left .content,
.left .top,
.left .bottom {
  border: 1px solid white;
}
.left .top,
.left .bottom {
  height: 5%;
  background-color: gray;
}
.left .content {
  height: 30%;
  background-color: #a09898;
}
.right {
  width: 85%;
  height: 100%;
  background-color: gray;
}
.right::after {
  content: '';
  display: table;
  clear: both;
}
<div class="wrapper">
  <div class="left">
    <div class="label-top">Label</div>
    <div class="top"></div>
    <div class="content"></div>
    <div class="content"></div>
    <div class="content"></div>
    <div class="bottom"></div>
    <div class="label-bottom">Label</div>
  </div>
  <div class="right"></div>
</div>

关于CSS block 布局全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30328328/

相关文章:

jquery - 软键盘在显示时调整移动网络的大小

android - 如何使 flutter 小部件扩展到其父小部件之外

android - 在 android 屏幕上安装 recyclerview 项目

css - Chrome/Safari无法填充Flex父级的100%高度

html - Div 元素未定位为粘性

html - IE Edge 上的 Flexbox 中出现 `display: table` 问题,后跟可滚动内容

html - 减少输入文本和底部边框之间的间距

layout - 使用 jQuery Mobile 和响应式布局/CSS 媒体查询是否多余?

javascript - 将 html Canvas 对齐到网页的绝对顶部

html - 将按钮与 div 中心对齐