IE8自动关闭标签 [英] IE8 self closing tags automatically

查看:77
本文介绍了IE8自动关闭标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在尝试调试我的布局,并查看为什么它在IE8及以下版本中都很时髦.当我开始观察代码时,我意识到内部元素的所有包装元素都将自行闭合.

Ok I'm trying to debug my layout and see why it's all funky in IE8 and below.. well when I start observing the code, I realize all the wrapping elements of inner elements are self closing themselves.

<section id="top-bar"/>
<div class="container">
  <div class="row">
    <div class="span12">
      <p>ELEMENTS</p>
    </div>
  </div>
</div>
<div class="rivets"/>
</section/>

我在CSS的#top-bar中应用了样式:

Well I have styling applied to the #top-bar in my CSS:

#top-bar {
  background: #146c7e url('../images/top-bar-bg.png') repeat top left;
  color: #fff;
}

因此,在IE8及以下版本中,不会应用该样式.这绝对令人沮丧.这只会在Magento中发生..如果内容不是直接放在其中,我自己做的所有其他布局也不会自行关闭.

So in IE8 and below that style is not being applied. This is absolutely frustrating. This only happens to me in Magento.. All my other layouts I did on my own never self closed themselves if content wasn't directly inside of them.

好吧,人们以为我自己添加了这些结束标记,但这是我的代码:

Ok people thought I was self adding those ending tags, but here is my code:

<section id="top-bar">
        <div class="container">
            <div class="row">
                <div class="span7">
                    <a href="#" class="tab">Shoppe</a>
                    <a href="#" class="tab">Local</a>
                    <a href="#" class="tab">Half Baked</a>
                </div>
                <div class="span5 mag-links">
                    <?php echo $this->getChildHtml('topLinks') ?>
                </div>
            </div>
        </div>
            <div class="rivets"></div>
    </section>

IE8被自动添加这些标签.我无法删除它们.因此该代码在Chrome,Firefox,IE9及更高版本中都可以正常工作.但是在IE8及以下版本中,它会启动自动关闭功能.我从来没有遇到过这个问题.

IE8 is adding those tags AUTOMATICALLY. I can't delete them.. hence the code works great in Chrome, Firefox, IE9 and up.. But IE8 and below, it starts that self-closing stuff. I NEVER had this problem before.

推荐答案

我认为这是因为IE8不支持HTML5标签,例如section.如果要使此功能在IE8中正常运行,请在文档标题中调用以下内容:

I think this is happening because IE8 does not support HTML5 tags, like section. If you want to get this to work in IE8, call the following in the head of your document:

<!--[if lt IE 9]>
  <script>
    document.createElement('header');
    document.createElement('nav');
    document.createElement('section');
    document.createElement('article');
    document.createElement('aside');
    document.createElement('footer');
    document.createElement('hgroup');
  </script>
<![endif]-->

这告诉IE8创建这些元素,并且以后应该能够将它们识别为HTML元素.

This tells IE8 to create these elements, and it should be able to recognize them as HTML elements afterwards.

这篇关于IE8自动关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆