我试图在我的网站中实现灵活的盒子模型,虽然它适用于像Chrome和safari这样的-webkit浏览器,其他浏览器如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可能存在语法问题,但是正如我所说的那样在其他浏览器中工作正常。有什么建议或提示吗?
答案 0 :(得分:5)
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 +