gpt4 book ai didi

css - 流体网格问题

转载 作者:行者123 更新时间:2023-11-28 14:33:11 25 4
gpt4 key购买 nike

我的第一个流体网格布局有问题。在大多数浏览器中,此布局看起来都移位了(宽度不同)。它仅适用于 firefox。(不适用于 chrome 或 opera)我不明白为什么。

谢谢

<!DOCTYPE html>
<html>
<head>
<title>Grid Test</title>
<style type="text/css">
.col {
float:left;
background-color: grey;
margin-left: 1%;
margin-right: 1%;
margin-top: 1px;
margin-bottom: 1px;
height: 50px;
text-align: center;
}

.one_quater {
width: 23%;
}
.two_quater {
width: 48%;
}
.three_quater {
width: 73%;
}

.one_thirds {
width: 31.333%;
}
.two_thirds {
width: 64.666%;
}

.one_half{
width: 48%;
}

.one_full{
width: 98%;
}

.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
</style>
</head>
<body>
<div class="row">
<div class="col one_full">
1/1
</div>
</div>
<div class="clear"></div>

<div class="row">
<div class="col one_thirds">
1/3
</div>
<div class="col one_thirds">
1/3
</div>
<div class="col one_thirds">
1/3
</div>
<div class="clear"></div>
</div>


<div class="row">
<div class="col two_thirds">
2/3
</div>
<div class="col one_thirds">
1/3
</div>
<div class="clear"></div>
</div>


<div class="row">
<div class="col one_thirds">
1/3
</div>
<div class="col two_thirds">
2/3
</div>
<div class="clear"></div>
</div>


<div class="row">
<div class="col one_half">
1/2
</div>
<div class="col one_half">
1/2
</div>
<div class="clear"></div>
</div>

<div class="row">
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="clear"></div>
</div>

<div class="row">
<div class="col two_quater">
2/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="clear"></div>
</div>


<div class="row">
<div class="col one_quater">
1/4
</div>
<div class="col two_quater">
2/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="clear"></div>
</div>

<div class="row">
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="col one_quater">
1/4
</div>
<div class="clear"></div>
</div>


<div class="row">
<div class="col one_quater">
1/4
</div>
<div class="col three_quater">
3/4
</div>
<div class="clear"></div>
</div>

</body>
</html>

最佳答案

您走在正确的轨道上。不同渲染的原因与 pixel rounding 有关。这是所有浏览器的问题,尤其是 IE。

查看 this fiddle查看兼容性建议

关于css - 流体网格问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7098973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com