【问题标题】:Why footer doesn't appear correctly in Internet Explorer 8 and 11?为什么页脚在 Internet Explorer 8 和 11 中无法正确显示?
【发布时间】:2015-03-07 18:59:42
【问题描述】:

在代码标签中 Main 和 Footer 放置在同一级别。

 <main class="Full">
  <div class="Sleeve">
   <div class="Columns">
     <div class="LeftCol">	 </div>
	 <div class="RightCol">   </div>
    </div>
   </div>	
  </main>
  <footer class="Full">
     <div class="Sleeve">
	   <div class="FooterData"> 2014 - 2015<div id="mymap"></div></div>
     </div>
  </footer>

但是 IE11 在 div.RightCol 之后将 Footer 删除到 Main。我不明白为什么IE重新设计DOM这么奇怪? p.s.我希望页脚始终放在页面底部,因此对于 CSS 中的页脚,我指定位置:绝对。也许是麻烦的原因?还是IE不能定义标签Footer和Main(Doctype - html5)的原因?


页脚在关闭主标签之后。


非常感谢!这正是我所需要的。


UPD:确实,在 IE11 中一切正常,我在 html 代码中犯了错误。对于误导性问题,我深表歉意。

【问题讨论】:

  • 因为footer是一个html5标签。请参阅 caniuse 网站上的caniuse html5 semantic。当然,这只能解释您与 IE8 相关的问题。
  • 感谢本站!那么,我在 IE11 中的问题是因为所有版本的 IE 都不支持 Main?
  • 至于 IE11 问题肯定出在其他地方,但没有 CSS 就很难猜到了。你能发布你的 CSS 样式吗?
  • 除了更改标签,还有什么救生窍门吗?
  • main{ min-height:100%;填充:0 0 30px;位置:相对;顶部:-15px; }

标签: css internet-explorer dom position absolute


【解决方案1】:

标签mainfooter 来自HTML5 语义。在 Internet Explorer 中,从版本 9 开始支持 HTML5 标签。请参阅caniuse website

因为 IE8 不能识别这些标签,所以你的 DOM 是乱七八糟的。但是,如果您想在 IE8 中“启用”这些标签,有一个解决方案。

您必须在项目中导入一个名为 html5shiv 的库。然后,在您页面的&lt;head&gt; 中,添加以下内容:

<!--[if lt IE 9]>
    <script src="path/to/html5shiv/html5shiv.js"></script>
<![endif]-->

这是一个条件注释,含义如下:

如果浏览器是lt IE9(=小于IE9),加载脚本html5shiv

如果加载,脚​​本将创建缺少的元素:

article 
aside 
figcaption 
figure 
footer 
header 
main 
nav 
section

还有一些其他的。

【讨论】:

    猜你喜欢
    • 2011-04-12
    • 2011-07-28
    • 2011-03-31
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多