【发布时间】:2016-03-10 01:45:26
【问题描述】:
我无法在 DIV 中将按钮居中。
我目前得到的结果是:
HTML 是:
<div id="buttonDiv">
<div class="button">
<button type="submit" onClick="setSid()">Click here to Start Test</button>
</div>
</div>
CSS 包括:
#buttonDiv {
position: fixed;
width:200px;
height:200px;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -100px;
border-bottom-width:1px;
border-top-width:1px;
border-right-width:1px;
border-left-width:1px;
border-style:solid;
border-color:#000000;
}
.button {
display:table-cell;
align-content:center;
vertical-align:middle;
}
我相信这条路线应该适用于文本,但似乎不适用于按钮。我尝试将类直接添加到按钮中,但没有任何乐趣。
谢谢
【问题讨论】:
标签: html css position alignment center