临时解决方案:我用浮动替换了 inline-block,并应用了这个站点的一些解决方案。但是,我将@media(最大宽度:800px)之类的东西更改为@media(最大宽度:50em)。
这更好但还不是最优的,因为我仍然需要为大量设备添加大量@媒体。将内容(文本)拟合到图块也存在潜在问题,但我想我可以以某种方式使用 calc() 将图块内的字体大小与图块本身成比例。
工作示例(实验性 - 关键是图块大小取决于字体大小和屏幕宽度):
<html>
<style>
body {
margin: 0;
padding: 0;
color: red;
}
.tile {
float: left;
position: relative;
width: 20%;
padding-bottom: 20%;
}
.content {
position: absolute;
left: 0.5em;
right: 0.5em;
top: 0.5em;
bottom: 0.5em;
background-color: #000;
}
@media (max-width: 50em){
.tile{
width: 50%;
padding-bottom: 50%;
}
}
</style>
<div class=tile>
<div class = content>
yay
</div>
</div>
<div class=tile>
<div class = content>
it
</div>
</div>
<div class=tile>
<div class = content>
works!
</div>
</div>
<div class=tile>
<div class = content>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>
</div>
<div class=tile>
<div class = content>
</div>
</div>
<div class=tile>
<div class = content>
</div>
</div>
<div class=tile>
<div class = content>
</div>
</div>
<div class=tile>
<div class = content>
</div>
</div>
<div class=tile>
<div class = content>
</div>
</div>
</html>