在 IE/Edge 中将 <HR> 向右对齐

Ker*_*n D 2 html css internet-explorer flexbox microsoft-edge

尝试将此页面上的一些<hr>元素向右对齐。在 IE/Edge 中,<hr>元素在每种情况下都左对齐。

我在用<hr class="hr-right">

.hr-right {
  text-align: right;
  margin-right: 0;
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用浮动和清除,但最终显示<hr>为段落内的浮动图像。

Mic*_*l_B 5

如果您希望元素在 Flex 容器中右对齐,请使用:

margin-left: auto
Run Code Online (Sandbox Code Playgroud)

不是

margin-right: 0;
Run Code Online (Sandbox Code Playgroud)

Flex 自动边距通过消耗所有可用的可用空间来工作。

因此margin-left: auto将消耗项目左侧的所有空间,将其固定到右边缘。

更多详细信息请参见此处: