Flexbox替代IE9 [英] Flexbox alternative for IE9

查看:1560
本文介绍了Flexbox替代IE9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Chrome网站(最容易设计),但现在我得到了IE支持模型。

I have developed a website with Chrome initially (easiest to design for) but now am getting to IE support model.

这就是说,我开始与IE11和对IE和IE之间的奇特差异进行了必要的更改。铬。但现在我下台IE版本。我能够得到90%的网页正确显示与IE10的CSS。但现在我对这两个浏览器的大多数CSS元素是大部分与IE9无关。

That being said, I started with IE11 and made the necessary changes for the quirky differences between IE & Chrome. But now I am stepping down the IE versions. I was able to get 90% of the webpages to display correctly with CSS for IE10. But now most of the CSS elements that I have for these two browsers, are for the most part irrelevant for IE9.

我想保持从需要有多个浏览器

I would like to keep from needing to have multiple browser specific style sheets, if possible.

第一个问题是转换IE10 +实现CSS的flexbox模型。

First problems is converting IE10+ implementation of the flexbox model of CSS.

flexbox容器的当前实现:

Current Implementation for the flexbox container:

div#navContainer{
    display: flex; //Current browsers (IE11, Chrome, etc)
    display: -ms-flexbox; //IE10 implementation
}

div#TeamsSection {
    text-align: center;
}

div.NavSection {
    margin: 0px 7px;
    padding: 4px 0px 0px 0px;
}

div#teams {
    margin: 0px;

    select {
        margin: 0px;
    }
}

HTML:

<div id="navContainer" class="float-left">
    <div id="LogoSection" class="NavSection">
        <div id="Logo">
            <img src="Images/Logo.png" />
        </div>
    </div>
    <div id="TeamsSection" class="NavSection">
        <label>Select a Team:</label><br />
        <div id="teams"></div>
    </div>
    <div id="UserSection" class="NavSection hidden">
        <label>Select a User:</label><br />
        <div id="requestor"></div>
    </div>
</div>

我知道IE9不实现Flexbox,所以请不要侮辱我已经做过的研究。我需要一个等效的实现,这将允许我尽可能少地更改HTML。

I know IE9 does not implement Flexbox, so please don't insult the research I have already done. I need an equivalent implementation that will allow me to change the HTML as little as possible.

推荐答案

使用 modernizr 来检测是否存在flex功能,并在必要时提供回退样式。 Modernizr将添加类 flexbox no-flexbox flexbox-legacy 到html元素,所以在你的样式你可以使用:

Use modernizr to detect whether flex capabilities are present, and provide fallback styles where necessary. Modernizr will add classes like flexbox, no-flexbox, and flexbox-legacy to the html element, so in your styles you can use:

    .container {
        display: flex;
    }
    .no-flexbox .container {
        display: table-cell;
    }



我强烈推荐阅读Zoe Gillenwater的( @ zomigi )关于此主题的演示文稿,特别是调平使用Flexbox(智能网络会议 - 2014年9月)

I highly recommend reading through Zoe Gillenwater's (@zomigi) presentations on the subject, particularly Leveling Up With Flexbox (Smart Web Conference - September 2014)


  • 幻灯片21:水平导航间距> display:inline-block;

  • slide 62:固定没有flexbox的元素> display:table-cell;

  • slide 70,71:对齐形式备用

  • slide 88,91:包含和不包括弹性订单的示例

  • slide 21: horizontal navigation spacing > display: inline-block;
  • slide 62: pinning elements without flexbox > display: table-cell;
  • slide 70,71: aligning forms fallbacks
  • slide 88,91: example with and without flex order

此外,在她的演示文稿 CSS3布局中,是具有和不具有flexbox的布局的几个好的并排预览:

Also, in her presentation CSS3 Layout, there are a few good sideby side previews of layouts with and without flexbox:


  • slide 73:使用带有flexbox的inline-block: li>
  • slide 79:使用带有flexbox的inline-block:水平导航

  • browser support ie10+ is pretty good caniuse
  • use auto-prefixr to handle browser prefixes
  • use modernizr to provide fallbacks
  • "flexbox is not all or nothing" @zomigi

这篇关于Flexbox替代IE9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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