在网页内容上,我尝试对齐顶部和底部的3个模块的内容。内容底部对齐不起作用,无法弄清楚为什么
使用flex,3个模块具有相同的高度。模块标题很好地对齐。 但不可能底部对齐按钮:
#container {
\t \t display: flex;
\t \t align-items: stretch;
\t }
\t
\t .module {
\t \t margin-right: 2em;
\t \t border: 1px solid white;
\t \t flex-basis: 30%;
\t }
<div style="text-align: center;">
\t <h1>Title</h1>
\t <h2>tagline</h2>
\t <div id="container">
<!-- Module1 -->
<div class="module" style="background-color: red;">
<table>
<tbody>
<tr>
<td valign="top">
<p><strong>Module 1</strong></p>
<p>lorem ipsum</p>
<p>lorem ipsum</p>
<p>lorem ipsum</p>
</td>
</tr>
<tr>
<td valign="bottom">
<div id="mc_embed_signup">
<form>
<div>
<div><input name="EMAIL" type="email" value="" placeholder="email address" /></div>
</div>
<div><input type="submit" value="button" /></div>
</div>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Fin module 1, début module 2 -->
<div class="module" style="background-color: green;">
<table>
<tbody>
<tr>
<td valign="top">
<p><strong>Module 2</strong></p>
</td>
</tr>
<tr>
<td valign="bottom">
<div>
<form>
<div>
<div><input name="EMAIL" type="email" placeholder="email address" /></div>
</div>
<div class="clear"><input name="subscribe" type="submit" value="button" /></div>
</div>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Fin module 2, début module 3 -->
<div class="module" style="background-color: yellow;">
<table>
<tbody>
<tr>
<td valign="top">
<p><strong>Module 3</strong></p>
<p>lorem ipsum</p>
</td>
</tr>
<tr>
<td valign="bottom">
<div>
<form>
<div>
<div ><input name="EMAIL" type="email" placeholder="email address" /></div>
</div>
<div class="clear"><input name="subscribe" type="submit" value="button" /></div>
</div>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Fin module 3 -->
</div>
</div>
为了实现这个底部对齐,我用一个简单的表的HTML代码,as suggested here。
它在这里不起作用。我做错了什么?
你能告诉我们首选的HTML?这完全有可能不使用表格和只是flexbox。 –
[对齐Flex项目的方法](http://stackoverflow.com/a/33856609/3597276) –