您好,我有這個顯示表格的按鈕。
<input id="toggleVisibilityButton" type="button" value="Button1"/>
和按鈕的這個功能
document.getElementById("toggleVisibilityButton").addEventListener("click", function(button) {
if (document.getElementById("tabel_in_reparatie").style.display === "none")
{document.getElementById("tabel_in_reparatie").style.display = "block";}
else document.getElementById("tabel_in_reparatie").style.display = "none";
});
我想讓表格居中,我該怎么做?注意:我嘗試以此為中心
#tabel_in_reparatie {
margin-left:auto;
margin-right:auto;
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
}
但它不會作業。
uj5u.com熱心網友回復:
使表格居中的最簡單方法是使用 flexbox。
.flexbox {
display: flex;
justify-content: center;
}
td, tr, th {
border: 4px solid black;
padding: 10px;
}
<div class="flexbox">
<table>
<tr>
<th>Head1</th>
<th>Head2</th>
</tr>
<tr>
<td>Cell1</td>
<td>Cell2</td>
</tr>
<tr>
<td>Cell1</td>
<td>Cell2</td>
</tr>
</table>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/407974.html
標籤:
下一篇:如何阻止表單標簽內的按鈕提交資料
