我可以用什么来代替css box-sizing?

What can i use instead of css box-sizing?

提问人:Javad-M 提问时间:3/13/2020 最后编辑:Javad-M 更新时间:3/19/2020 访问量:436

问:

我有以下代码。我不想使用IE(6-7)等某些浏览器不支持的,我该如何解决我的问题,以便仍然具有相同的顺序?我希望浮动 div 之间的间隙保持不变。htmlcssbox-sizing:border-boxcssdiv

div[class="clmn"]{
border:solid .1em ;
background-color: rgba(255, 0, 0, 0.1);
width:33.13%;
padding:0.2em;
margin:.1%;
box-sizing:border-box;
}

div[id="div0"]{
background-color:rgba(0,0,255,0.1);
border:solid 1px red;
overflow:auto;

}

#div1{
float:left;
}

#div2{
float:right;
}

#div3{
float:right;
}

#div4, #div00{
width:100%;
}
<!DOCTYPE html>
<html>
<head>

</head>
<body>
<div id="div00" class="clmn"> This is div 00</div>
<div id="div0">
<div id="div1" class="clmn"> This is div 1</div>
<div id="div2" class="clmn"> This is div 2</div>
<div id="div3" class="clmn"> This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3</div>

</div>
<div id="div4" class="clmn"> This is div 4</div>

</body>
</html>

HTML CSS 互联网浏览器-7

评论

2赞 Quentin 3/13/2020
IE 7 太旧了,它无法在任何有安全更新的操作系统上运行。你应该鼓励人们升级运行它的系统,而不是迎合他们。
1赞 andergtk 3/13/2020
你真的想支持IE 6-7吗?
2赞 Spudley 3/13/2020
一句话:如果你绝对必须支持 IE7,那么你需要使用 IE7 时常用的技术,因为这是有效的。在这种情况下,这可能意味着添加额外的元素层,以便对盒子进行更精细的控制。但坦率地说,盒子尺寸将是你最不关心的问题。<div>
1赞 Lalji Tadhani 3/13/2020
stackoverflow.com/questions/2909667/box-sizing-support-in-ie7/......
1赞 Dejan.S 3/13/2020
获取新的工作b/客户...甚至不是开玩笑

答:

0赞 Deepak-MSFT 3/16/2020 #1

我找到了 box-sizing:border-box 的 polyfill,它可以帮助您解决 IE 7 浏览器的问题。

您可以从下面的链接下载 polyfill。

CSS box-sizing: IE 6/7 的边框框 polyfill

您需要在CSS代码中的此行box-sizing: border-box之后包含它。

box-sizing: border-box; *behavior: url(/scripts/boxsizing.htc);

修改后的代码:

<!DOCTYPE html>
<html>
<head>
<style>
div[class="clmn"]{
border:solid .1em ;
background-color: rgba(255, 0, 0, 0.1);
width:33.13%;
padding:0.2em;
margin:.1%;
box-sizing:border-box;
*behavior: url(/boxsizing.htc); /*User need to modify the URL here...*/
}

div[id="div0"]{
background-color:rgba(0,0,255,0.1);
border:solid 1px red;
overflow:auto;

}

#div1{
float:left;
}

#div2{
float:right;
}

#div3{
float:right;
}

#div4, #div00{
width:100%;
}
</style>
</head>
<body>
<div id="div00" class="clmn"> This is div 00</div>
<div id="div0">
<div id="div1" class="clmn"> This is div 1</div>
<div id="div2" class="clmn"> This is div 2</div>
<div id="div3" class="clmn"> This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3. This is div 3.This is div 3</div>

</div>
<div id="div4" class="clmn"> This is div 4</div>

</body>
</html>

在 IE 11 浏览器中使用 IE 7 文档模式输出:

enter image description here

注意:IE 7 浏览器很久以前就不再受支持了。不建议使用 IE 7 浏览器。我建议您使用最新的Microsoft浏览器。如果您无法升级到最新的 Microsoft 浏览器,那么至少要迁移到 IE 11 浏览器。