获得按钮3和按钮的最佳方式是什么?按钮1和1旁边的垂直列中的4 2.我想把它们放在一个表中来分隔它们,但是想看看CSS中是否有更好的想法?
以下工作示例:https://jsfiddle.net/Jaron787/0te3cs66/1/
代码:
HTML
<div id="lse" class="display">
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
</div>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
CSS
</div>
.TSS {
border: 1px solid #000000;
float: none;
font-family: Verdana,Geneva,sans-serif;
font-size: 10.6px;
font-style: normal;
padding: 10px;
text-decoration: none;
display: inline-block;
}
#centertbl {
text-align: center;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
答案 0 :(得分:2)
您也可以随时使用flexbox。这是一个例子。如果您想更改按钮的顺序,只需更改html中的顺序。
https://jsfiddle.net/GJordan/yoj1m8jf/
<强> HTML 强>
<div class="btn-container">
<input type="submit" class="button" name="submitButton" value="Button 1">
<input type="submit" class="button" name="submitButton" value="Button 3">
<input type="submit" class="button" name="submitButton" value="Button 2">
<input type="submit" class="button" name="submitButton" value="Button 4">
</div>
<强> CSS 强>
.btn-container {
display: flex;
flex-wrap: wrap;
width: 250px;
}
.button {
margin: 1%;
width: 45%;
}
答案 1 :(得分:0)
制作aligment thorugh CSS将按钮按1 3和2 4对齐2行,只需浮动并显示内联属性,
https://jsfiddle.net/0te3cs66/2/
上面的是所需答案的工作示例:表格
下面是代码
<div id="lse" class="display">
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
</div>
<table>
<tr>
<td> <input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2"></td>
<td> <input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4"></td>
</tr>
</table>
</div>
答案 2 :(得分:0)
将按钮放在表格标签
中非常简单 <table>
<tr>
<td>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
</td>
<td>
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
</td>
</tr>
</table>