您好父母div main-section
和两个孩子div leftContent
和rightContent
彼此相邻。
我希望孩子的身高与父母的身高相同。此外,我希望main-section
获取页面中的所有垂直空间,以防main-section
中的内容不是那么多。这意味着如果内容不足,页脚将始终保留在页面底部。
我的代码适用于Chrome,Safari和Firefox,但不适用于IE 11。
JS小提琴 - https://jsfiddle.net/2qbw21xk/
这是预期的 -
这就是IE中发生的事情
请帮忙!
提前致谢!
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>XXXXXXXXX</title>
<meta name="description" content="XXXXXXXXXXXXXXXXX">
<meta name="author" content="XXXXXXXXXXXXXXXXXXXX">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
</head>
<style>
/*----------GLOBAL-------*/
.container{
width: 97%;
margin: auto;
overflow: hidden;
}
.centerAlign{
text-align: center;
}
/*----------HEADER-------*/
header{
height: 102px;
}
header div img{
top: 6px;
position: relative;
}
.logo_mobile {
display: none;
}
@media only screen and (max-width: 1100px) {
.logo_mobile {
display: inline;
position: relative;
top: 25px;
}
.logo_desktop {
display:none;
}
}
/*----------TOPNAV-------*/
nav {
background-color: #182d3c;
color: #fff;
height: 50px;
border-bottom: 4px solid #ffd100 !important;
}
nav div ul li{
display:inline;
}
.navContent{
position: relative;
top: 6%;
height: inherit;
}
/*----------MAIN BODY-------*/
html,
body {
height: 100%;
overflow-x: hidden;
}
.main-section{
min-height: calc(100% - 291px);
min-height: -webkit-calc(100% - 291px);
display: flex;
}
.header{
border-bottom: 1px solid #e8e8e8;
}
.question{
}
.buttons{/* border-top: 1px solid #e8e8e8; */}
/*---------------RIGHT CONTENT---------------*/
.rightContent{
overflow: hidden;
border-left: 1px solid #e8e8e8;
flex:2;
}
/*----LEFT CONTENT---*/
.leftContent{
float:left;
flex:7;
}
.header{
}
.buttons{
}
.question{
}
/*----------Footer------*/
footer{
clear: both;
position: relative;
background-color: #e9eef2;
min-height: 135px;
width: 100%;
text-align: center;
}
.footerHead{
font-weight:400;
font-size: 20px;
color: #606d75;
}
/*-----HAMBURGER_____*/
#hamburger_icon{
float:left;
height:22px;
width: 22px;
display: none;
}
/*----RIGHT PANEL MOBILE-----*/
@media only screen and (max-width: 1100px) {
.leftContent{
width:100%;
}
.rightContent{
display:none;}
}
</style>
<body>
<header>
<div class="container centerAlign">
<img>
</div>
</header>
<nav>
<div class="container centerAlign navContent">
<img src="hamburger.png" id="hamburger_icon">
<ul>
<li>XXX</li>
<li>XXX</li>
<li>XXX</li>
</ul>
</div>
</nav>
<section class="main-section">
<div class="leftContent">
<div class="header" id="innerPageHeadingWrap">
<P>TITLE SECTION</P>
</div>
<div class="question">
<P>QUESTION SECTION</P>
</div>
<div class="buttons">BUTTON SECTION
</div>
</div>
<div class="rightContent">
<p>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>
</div>
</section>
<footer>
<div class="footerContent container centerAlign">
<p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
<p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
</div>
</footer>
</body>
</html>
答案 0 :(得分:0)
使用flex属性使main-section
消耗所有剩余空间。
适用于各种浏览器,包括IE11。
body {
display: flex;
flex-direction: column;
}
header {
flex: 0 0 102px; /* can't grow, can't shrink, fixed at 102px height */
}
nav {
flex: 0 0 50px;
}
.main-section {
flex-grow: 1; /* consume all remaining space */
}
footer {
flex: 1 0 135px; /* can grow, can't shrink, start at 135px height */
}
body {
display: flex;
flex-direction: column;
}
header {
flex: 0 0 102px;
}
nav {
flex: 0 0 50px;
}
.main-section {
flex-grow: 1;
}
footer {
flex: 1 0 135px;
}
/*----------GLOBAL-------*/
.container {
width: 97%;
margin: auto;
overflow: hidden;
}
.centerAlign {
text-align: center;
}
/*----------HEADER-------*/
header {
flex: 0 0 102px;
}
header div img {
top: 6px;
position: relative;
}
.logo_mobile {
display: none;
}
@media only screen and (max-width: 1100px) {
.logo_mobile {
display: inline;
position: relative;
top: 25px;
}
.logo_desktop {
display: none;
}
}
/*----------TOPNAV-------*/
nav {
background-color: #182d3c;
color: #fff;
height: 50px;
border-bottom: 4px solid #ffd100 !important;
}
nav div ul li {
display: inline;
}
.navContent {
position: relative;
top: 6%;
height: inherit;
}
/*----------MAIN BODY-------*/
html,
body {
height: 100%;
overflow-x: hidden;
}
.main-section {
/* min-height: calc(100% - 291px);
min-height: -webkit-calc(100% - 291px); */
display: flex;
}
.header {
border-bottom: 1px solid #e8e8e8;
}
.question {}
.buttons {
/* border-top: 1px solid #e8e8e8; */
}
/*---------------RIGHT CONTENT---------------*/
.rightContent {
overflow: hidden;
border-left: 1px solid #e8e8e8;
flex: 2;
}
/*----LEFT CONTENT---*/
.leftContent {
float: left;
flex: 7;
}
.header {}
.buttons {}
.question {}
/*----------Footer------*/
footer {
clear: both;
position: relative;
background-color: #e9eef2;
min-height: 135px;
width: 100%;
text-align: center;
}
.footerHead {
font-weight: 400;
font-size: 20px;
color: #606d75;
}
/*-----HAMBURGER_____*/
#hamburger_icon {
float: left;
height: 22px;
width: 22px;
display: none;
}
/*----RIGHT PANEL MOBILE-----*/
@media only screen and (max-width: 1100px) {
.leftContent {
width: 100%;
}
.rightContent {
display: none;
}
}
&#13;
<header>
<div class="container centerAlign">
<img>
</div>
</header>
<nav>
<div class="container centerAlign navContent">
<img src="hamburger.png" id="hamburger_icon">
<ul>
<li>XXX</li>
<li>XXX</li>
<li>XXX</li>
</ul>
</div>
</nav>
<section class="main-section">
<div class="leftContent">
<div class="header" id="innerPageHeadingWrap">
<P>TITLE SECTION</P>
</div>
<div class="question">
<P>QUESTION SECTION</P>
</div>
<div class="buttons">BUTTON SECTION
</div>
</div>
<div class="rightContent">
<p>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>
</div>
</section>
<footer>
<div class="footerContent container centerAlign">
<p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
<p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
</div>
</footer>
&#13;