我正在尝试使用CSS内联块作为创建徽标表的替代方法。

不幸的是,徽标并没有向下移动到下一行,而是彼此相邻放置(例如,参见下面示例中的箭头)

html - 强制CSS内联块显示到新行-LMLPHP

我的代码当前如下所示:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
<style type="text/css">
.gallery{
    display:block;
}
.thumbnail{
    display:inline-block;
    border:0px;
    float:left;
    max-width:250px !important;
    width: auto !important;
    height: auto !important;
    margin-left: 1cm;
    margin-right: 1cm;
    margin-top: 1cm;
    margin-bottom: 1cm;
}
</style>
</head>

<body>

<img class="gallery thumbnail" src=“X” alt=“Z” />
<img class="gallery thumbnail" src=“X” alt=“Z” />
<img class="gallery thumbnail" src=“X” alt=“Z”  />
<img class="gallery thumbnail" src=“X” alt=“Z”  />
<img class="gallery thumbnail" src=“X” alt=“Z”  />
<img class="gallery thumbnail" src=“X” alt=“Z”  />
<img class="gallery thumbnail" src=“X” alt=“Z”  />
<img class="gallery thumbnail" src=“X” alt=“Z” />

</body>

</html>

最佳答案

从.thumbnail中删除float: left;

.gallery{
    display:block;
}
.thumbnail{
    display:inline-block;
    border:0px;
    max-width:250px !important;
    width: auto !important;
    height: auto !important;
    margin-left: 1cm;
    margin-right: 1cm;
    margin-top: 1cm;
    margin-bottom: 1cm;
}

09-25 20:51