在網頁內容上,我嘗試對齊頂部和底部的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) –