我在使用 HTML 中的 hr
标记时遇到了一些问题,因为它没有像我期望的那样自动居中。这就是我当前的代码:
<div id = "updatestatus" class = "statuscontainer">
<div class = "verticalalign">Update Status</div>
</div>
<hr width = "95%">
<div id = "insertstatus" class = "statuscontainer">
<form></form>
</div>
如您所见,我将我的 hr
标记放在两个 div
之间,我相信它应该自动居中,但它最终会向左移动。我也试过 hr align = center
也没有成功。
编辑:我刚刚意识到,当我将整个 hr
标签放在 <center></center>
中时,它居中,但我仍在尝试弄清楚为什么它不以自己为中心。
原文由 Phil 发布,翻译遵循 CC BY-SA 4.0 许可协议
试试
margin: auto;