【问题标题】:IE flexible box model not workingIE 柔性盒模型不起作用
【发布时间】:2013-05-05 11:16:56
【问题描述】:

我试图在我的网站中实现灵活的盒子模型,虽然它适用于 chrome 和 safari 等 -webkit 浏览器,也适用于 mozilla 和 opera 等其他浏览器,但我似乎无法让它在 Internet Explorer 中运行,不不管我做什么。这是我的 Css 样式表文件的简短 sn-p 文件,其中包含我的 .holder 类,它包含所有内容,以及我的 #new_div id,它是 .holder 的子项,包含我的帖子和侧边栏的主要部分。

.holder
{
    width:100%;
    margin:auto;
    display:-webkit-box;
    display:-o-box;
    display:-ms-box;
    display:-box;
    display:-pie;
    -webkit-box-orient:vertical;
    -moz-box-orient:vertical;
    -o-box-orient:vertical;
    -ms-box-orient:vertical;
    -box-orient:vertical;
    -pie-box-orient:vertical;
    -moz-box-flex:1;    /* Firefox, seamonkey etc */
    -o-box-flex:1;      /* Opera */
    -ms-box-flex:1;     /* MSIE */
    -box-flex:1;         /* Any that support full implementation */
    -pie-box-flex:1;
    -webkit-box-flex:1;
    -webkit-box-pack:center;
    -o-box-pack:center;
    -ms-box-pack:center;
    -pie-box-pack:center;
    -box-pack:center; 
    text-align:center;
    behavior: url(../../Content/pie/PIE.htc);
}

.holder #new_div
{
    width:940px;
}
.holder div
{
    -webkit-box-pack:center;
    -o-box-pack:center;
    -ms-box-pack:center;
    -box-pack:center; 
    -pie-box-pack:center;
    behavior: url(../../Content/pie/PIE.htc);
}
#new_div
{
    margin:auto;
    display:-webkit-box;
    display:-moz-box;
    display:-o-box;
    display:-ms-box;
    display:-box;
    display:-pie-box;
    text-align:left;
    -webkit-box-flex:1;
    -moz-box-flex:1;    /* Firefox, seamonkey etc */
    -o-box-flex:1;      /* Opera */
    -ms-box-flex:1;     /* MSIE */ 
    -box-flex:1; 
    -pie-box:1;     
    -webkit-box-pack:center;
    -box-pack:center;
    -moz-box-pack:center;
    -o-box-pack:center;
    -ms-box-pack:center; 
    -pie-box-pack:center;
    background-color:#25282D;
    -webkit-box-orient:horizontal;
    -moz-box-orient:horizontal;
    -o-box-orient:horizontal;
    -ms-box-orient:horizontal;
    -box-orient:horizontal;
    -pie-box-orient:horizontal;
    min-width:940px; 
    padding:20px;
    behavior: url(../../Content/pie/PIE.htc);
}

你可以看到我在其他定义旁边定义了 -ms-box-.. 名称,但它似乎仍然没有注册。我已经绝望地尝试使用 CSS3Pie 库,尽管这没有用,尝试为 IE 安装 Chrome 插件,但也失败了,我只是不知道该怎么做。也许我已经写过的 css 可能存在语法问题,导致它被抛出,但正如我所说,它在其他浏览器中运行良好。有什么建议或提示吗?

【问题讨论】:

标签: css flexbox


【解决方案1】:

IE 不使用deprecated 2009 Flexbox properties,它使用已弃用的March 2012 draft 中的那些。 Opera 支持不带前缀的Flexbox standard 属性和-webkit- 前缀下的2009 属性。

.holder {
  width: 100%;
  margin: auto;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -moz-box-orient: vertical;
  -webkit-box-direction: normal;
  -moz-box-direction: normal;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-flex: 1;
  -moz-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
  -webkit-box-pack: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  text-align: center;
}

.holder #new_div {
  width: 940px;
}

.holder div {
  /* justify-content does nothing here since this element isn't a flex container */
  -webkit-box-pack: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

#new_div {
  margin: auto;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  text-align: left;
  -webkit-box-flex: 1;
  -moz-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
  -webkit-box-pack: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  /* this shouldn't be necessary, as the default direction is `row` */
  -webkit-box-orient: horizontal;
  -moz-box-orient: horizontal;
  -webkit-box-direction: normal;
  -moz-box-direction: normal;
  -webkit-flex-direction: row;
  -ms-flex-direction: row;
  flex-direction: row;
  min-width: 940px;
  padding: 20px;
}

另外值得注意的是,这需要IE10+

【讨论】:

  • 只是为了弄清楚这一点,justify-content:column 是在 2012 年 3 月的版本中与 flex 方向一起添加的?使用 orient:horizo​​ntal 的 -webkit- 和 -moz- 前缀,就不再需要了,而是用 column?对于过早的响应问题,我很抱歉,我还是 css3 流的新手。
  • 您需要哪些属性取决于您要定位的浏览器。 Firefox 尚未过渡到使用标准属性,它仍然停留在 2009 年。Safari 和除 Blackberry 10 之外的所有移动 webkit 浏览器也是如此。gist.github.com/cimmanon/727c9d558b374d27c5b6
  • 谢谢兄弟!!!感谢您的帮助和支持,我永远不会知道这一点!
猜你喜欢
  • 2011-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-09
  • 1970-01-01
  • 1970-01-01
  • 2023-01-03
  • 2013-07-24
相关资源
最近更新 更多