html - 带有页眉和页脚的可滚动 div

标签 html css

我有一个聊天模板,其中包含标题(聊天用户列表,我不知道标题的高度,它取决于人数,所以固定高度不划算)和页脚(消息文本区域字段)。我想在这两个 div 之间放置消息。使用 display: table for parent 和 display: table-row with 1px height for header and footer 仅在 webkit 浏览器中工作良好,firefox 和 IE 忽略它。有一个 example .有没有办法在所有浏览器(webkit、firefox、IE8+)上都正常工作?

由于旧浏览器的支持,无法使用 Flexboxes 和 calc 属性。

最佳答案

*{margin:0;
	  padding:0;
	  }
body{
	background:#fff; 
	position:absolute; 
	width:100%; 
	height:100%;
	}
.main{
	background:#0C0;
	height:100%; 
	padding:60px 0 40px; 
	box-sizing:border-box;
	}
.header{
	background: #0FC;
	position:absolute; 
	width:100%;
	height:60px;
	}
.left{
	background:#3CC; 
	float:left; 
	width:250px; 
	height:100%; 
	overflow:scroll;
	}
.right{
	background:#9F3; 
	height:100%; 
	overflow:scroll;
	}
.footer{
	background:#9F9; 
	position:absolute; 
	bottom:0; 
	width:100%; 
	height:40px;
	}
<div class="header"></div>
<div class="main">
    <div class="left">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.</div>
    <div class="right">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.
    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.</div>
</div>
<div class="footer"></div>

关于html - 带有页眉和页脚的可滚动 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40343793/

相关文章:

css - 如何让 div 水平生长到屏幕外

javascript - 使用 jQuery 动画顶部和底部位置

javascript - 淡入和淡出 block 中的文本

html - 如何创建底部有轮播缩略图且右侧有轮播标题的引导轮播

超出溢出自动 div 的 CSS flyout div

javascript - 使用 Gulp 4 使用 browserSync 重新加载时,SCSS/JS 更改不会被注意到

html - 菜单项不在同一水平线上

jquery - 一个按钮拉伸(stretch),其他是原始大小

html - 是否可以仅使用 CSS 设置永久动画按钮/链接的样式?

html - 网页溢出滚动条