微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css3 – IE灵活的盒子模型无法正常工作

我试图在我的网站中实现灵活的盒子模型,虽然它的工作为-webkit浏览器,如chrome和safari,其他浏览器,如mozilla和opera,我似乎无法让它在Internet Explorer中工作,无论我是什么做.下面是我的Css样式表文件的简短片段,其中包含我的.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可能存在语法问题,但是正如我所说的那样在其他浏览器中工作正常.有什么建议或提示吗?

解决方法

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

原文地址:https://www.jb51.cc/css/217239.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。