gpt4 book ai didi

HTML Flex 布局在 Internet Explorer 中看起来不同

转载 作者:行者123 更新时间:2023-12-04 08:10:51 26 4
gpt4 key购买 nike

我试图获得一个简单的 flex 布局,使其在 IE11 中的工作方式与在 Chrome 中的工作方式相同。
在 Chrome 中,它看起来像这样:
enter image description here
但是在 IE11 中它看起来像这样:
enter image description here
这是代码:

html,
body {
margin: 2px 0 0 0;
padding: 0;
}

.wrap {
display: flex;
min-height: calc( 100vh - 8px);
flex-direction: column;
max-width: 1200px;
margin: auto;
border: 1px solid #222222;
}

.main {
flex: 1 1 auto;
display: flex;
}

header {
background: green;
padding: 10px;
}

#footer {
background: green;
padding: 10px;
}

.sidebar {
background: blue;
flex: 0 0 135px;
padding: 10px;
}

.content {
background: yellow;
padding: 10px;
flex: 1 1 auto;
}

@media screen and (max-width:680px) {
.sidebar {
flex: 0;
order: 2
}
.main {
flex-direction: column;
}
}
<body translate="no">


<div class="wrap">


<header>

<div class="header-inner-left">
</div>

<div class="header-inner">
</div>

</header>

<main class="main">


<div class="sidebar">

</div>



<div class="content">


</div>


</main>



<div id="footer">
<div class='footerleft'>

</div>
<div class='footerright'>

</div>
<div style="clear: both;"></div>
</div>



</div>

</body>

这显示了 HTML 和 CSS。
有没有办法让这个看起来一样。
如果我设置 .wrap所以它使用:
height: calc( 100vh -  8px );
然后加载页面看起来是正确的,但我需要能够让内容正确地超出 .wrap,所以设置 min-height: calc( 100vh - 8px );有没有办法做到这一点?
谢谢

最佳答案

这是一个可能对您有用的想法:

body {
display: flex;
}

.wrap {
min-height: 100vh;
flex-grow: 1;
display: flex;
flex-direction: column;
max-width: 1200px;
border: 1px solid #222222;
}

.main {
flex: 1 1 auto;
display: flex;
}

header {
background: green;
flex: 0 0 25px;
}

#footer {
background: green;
flex: 0 0 25px;
}

.sidebar {
background: blue;
flex: 0 0 135px;
padding: 10px;
}

.content {
background: yellow;
padding: 10px;
flex: 1 1 auto;
}

body {
margin: 0;
}

* {
box-sizing: border-box;
}
<div class="wrap">
<header>
<div class="header-inner-left"></div>
<div class="header-inner"></div>
</header>
<main class="main">
<div class="sidebar"></div>
<div class="content"></div>
</main>
<div id="footer">
<div class='footerleft'></div>
<div class='footerright'></div>
<div style="clear: both;"></div>
</div>
</div>

关于HTML Flex 布局在 Internet Explorer 中看起来不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65968189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com