我有一个类似画廊的带有文本内容的块项目列表。使用 display: table* stuff 将文本内容与底部对齐。该列表不是固定宽度,因为它通过创建更多列扩展到视口宽度。我想使列表在屏幕上居中,这样底行仍将与所有其他行的左侧对齐(我无法弄清楚如何使用内联块的原因之一)。例子:
<!doctype html>
<html>
<head>
<title>test</title>
<style>
ul{
margin: 0;
padding: 0;
list-style: none;
}
ul:after{
display: block;
clear: both;
content: ' ';
}
li{
display: table;
float: left;
border: 1px solid red;
width: 300px;
height: 300px;
}
.gridRow{
display: table-row;
}
.gridCell{
display: table-cell;
vertical-align: bottom;
}
</style>
</head>
<body>
<ul>
<li><span class="gridRow"><span class="gridCell">1</span></span></li>
<li><span class="gridRow"><span class="gridCell">2</span></span></li>
<li><span class="gridRow"><span class="gridCell">3</span></span></li>
<li><span class="gridRow"><span class="gridCell">4</span></span></li>
<li><span class="gridRow"><span class="gridCell">5</span></span></li>
<li><span class="gridRow"><span class="gridCell">6</span></span></li>
<li><span class="gridRow"><span class="gridCell">7</span></span></li>
<li><span class="gridRow"><span class="gridCell">8</span></span></li>
<li><span class="gridRow"><span class="gridCell">9</span></span></li>
<li><span class="gridRow"><span class="gridCell">10</span></span></li>
<li><span class="gridRow"><span class="gridCell">11</span></span></li>
<li><span class="gridRow"><span class="gridCell">12</span></span></li>
<li><span class="gridRow"><span class="gridCell">13</span></span></li>
<li><span class="gridRow"><span class="gridCell">14</span></span></li>
<li><span class="gridRow"><span class="gridCell">15</span></span></li>
<li><span class="gridRow"><span class="gridCell">16</span></span></li>
<li><span class="gridRow"><span class="gridCell">17</span></span></li>
<li><span class="gridRow"><span class="gridCell">18</span></span></li>
<li><span class="gridRow"><span class="gridCell">19</span></span></li>
</ul>
</body>
</html>