简体   繁体   English

在 Internet Explorer 11 中,页脚显示在屏幕中间而不是底部

[英]Footer is displaying in middle of screen instead of bottom in Internet Explorer 11

In IE11, footer is displayed at middle of screen rather than on bottom.在 IE11 中,页脚显示在屏幕中间而不是底部。 I am using below CSS which was working file until we upgraded the browser to IE11.在我们将浏览器升级到 IE11 之前,我正在使用下面的 CSS,它是工作文件。

#footer {
    clear: both; 
    height:45px; 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    border: none; 
    width: 100%;
}

Note:- My page has a Tab views & we are using Layout template in MVC.注意:- 我的页面有一个选项卡视图,我们在 MVC 中使用布局模板。 Please suggest some solution.请提出一些解决方案。

There is nothing wrong with your CSS.您的 CSS 没有任何问题。 Based on experience, the only issue I can foresee, is that your footer has a parent element with the property position: relative;根据经验,我能预见的唯一问题是您的页脚有一个父元素,其属性position: relative;

This causes the "absolute" positioning to be relative to the parent and not the window itself.这会导致“绝对”定位相对于父级而不是窗口本身。

Also, you probably don't clear:both;另外,你可能没有clear:both; . . If you have floating elements inside footer, just add overflow: auto;如果页脚中有浮动元素,只需添加overflow: auto; and that will clear your floats!这将清除您的浮动!

It may now be less relevant as IE seems to be less and less popular, but the only thing IE properly recognizes as far as vertical positioning is concerned is div.它现在可能不太相关,因为 IE 似乎越来越不受欢迎,但就垂直定位而言,IE 唯一正确识别的是 div。 So what seems to have helped in my case is brute-forcing all elements, including the footer, into its own div:因此,在我的情况下似乎有帮助的是将所有元素(包括页脚)强行放入其自己的 div 中:

<div style={{position: "sticky", top: "0px", zIndex: "10"}} >
    <Nav />
</div>
<div>
    <C {...props} {...cProps} />
</div>
<div style={{marginTop: "20px"}}>
    <Footer />
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM