html - 居中 <hr> 标签

标签 html centering

我的 hr 有问题HTML 中的标记,因为它不会像我期望的那样自动居中。这就是我当前的代码:

<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 s,我相信它应该自动居中,但最终却偏向左侧。我也试过hr align = center也没有成功。

编辑:我刚刚意识到,当我放置整个 hr<center></center> 内标记它居中,但我仍在努力弄清楚为什么它不以自己为中心。

最佳答案

试试 margin: auto;

<hr style="width:100px; margin: auto;" />

关于html - 居中 <hr> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24749399/

相关文章:

html - 以其他 4 个 div 为中心的 div

html - 如何在导航栏中居中品牌/形象

css - 居中水平无序列表,没有固定宽度

php - 有没有办法让codeIgniter输出html而不是xhtml?

html - 如何仅使用 Twitter Bootstrap 中的一个元素?

php - 如何使 Web 应用程序在线和离线工作

html - 即 : "overflow: scroll" on parent and "margin: 0 auto" on child do not work properly

javascript - 使用预填充的表单,仅提交更改的字段

javascript - 是否可以在 Visual Studio 之外的不同 IDE 中开发 Win8 应用程序?

css - 如何在外部 div 内水平居中响应式 flexbox div