我有一个应该在导航菜单下居中的按钮框。出于某种原因,盒子不居中,元素正在通过导航菜单。如何居中按钮框?
如果使用开发工具并选择div(按钮框),您将看到该元素的位置。这会影响我的填充。在底部填充看起来很好,但在顶部是搞砸了。
这里是工作示例:
section.settingsBox {
width: 100%;
padding-top: 0;
float: left;
background-color: white;
border: 2px solid #000099;
}
nav.xNavigationSetting {
width: 100%;
margin-left: 0;
margin-right: 0;
padding-top: 2px;
background-color: #c8e2db;
float: left;
border-bottom: 2px solid #000099;
height: 18px;
}
nav.xNavigationSetting a {
color: black;
text-decoration: none;
cursor: pointer;
font-weight: bold;
padding-left: 5px;
padding-right: 5px;
}
nav.xNavigationSetting a:hover {
color: #999999;
}
div.buttonBox {
background-color: #c8e2db;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
border-bottom: 2px solid #000099;
}
<section class="settingsBox">
<div id="htmlSetting">
<nav class="xNavigationSetting">
<a href="#" data-id="settingMain">Menu</a> |
</nav>
<div id="settingTbl">
<div class="buttonBox">
<input type="button" name="settingButton" id="settingAdd" value="Add" />
</div>
<div class="settingsTblMaster">
<table>
<thead>
<tr>
<th>Test</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
如果有人可以帮助我解决这个问题,请让我知道。我很确定我的一些CSS属性导致了这个问题。提前致谢。
说实话,我不明白。 'div.buttonBox {text-align:center; ''为你工作? –