您如何更改hr标签的长度?

问题描述

如何更改hr标签的长度?

<hr>

获取浏览器的完整长度。我尝试设置填充和边距,但没有效果。使用纯CSS或Bootstrap 5对此有什么解决方案?

解决方法

您需要为hr标签设置边距。以下将起作用

hr {
  margin: auto 220px
}


/* just for demo*/
.div {
  text-align: center;
  margin: 20px;
}
<div class='div'> div - 1</div>

<hr>

<div class='div'> div - 2</div>

,

您可以在html上编写以下样式标签。

<style> hr{margin: auto 220px;}</style>
<hr>

Get more information here.