如何使用css选择器将此元素居中对齐?

如何使用css选择器将此元素居中对齐?,css,layout,flexbox,css-selectors,antd,Css,Layout,Flexbox,Css Selectors,Antd,试着把墨水条变成一个圆圈,我已经做了,但是,我有一个困难的时间尝试中心对齐它。谁能给我一些建议吗 .ant-tabs-ink-bar { display: flex; //align-items: center; //vertical-align: middle; width: 8px !important; height: 8px; line-height: 8px; border-radius: 50%; } 使用您提供的CSS,尝试以下操作 .ant-tabs

试着把墨水条变成一个圆圈,我已经做了,但是,我有一个困难的时间尝试中心对齐它。谁能给我一些建议吗

.ant-tabs-ink-bar {
  display: flex;
  //align-items: center;
  //vertical-align: middle;
  width: 8px !important;
  height: 8px;
  line-height: 8px;
  border-radius: 50%;
}

使用您提供的CSS,尝试以下操作

.ant-tabs-ink-bar {
  left: 22.5px;
  width: 8px !important;
  height: 8px;
  line-height: 8px;
  border-radius: 50%;
}

您可以创建一个伪元素

.ant-tabs-ink-bar {
  display: flex !important;
  justify-content: center;
  height: 8px;
  background-color: transparent;
}
.ant-tabs-ink-bar::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin-bottom: -4px;
  line-height: 8px;
  border-radius: 50%;
  background-color: var(--antd-wave-shadow-color);
}

只需将其包装在一个容器中,并向容器提供以下CSS

.container{
  display:flex;
  justify-content:center;
}

只需添加
.ant tabs墨水条{left:28px}
@demkovych谢谢。我以前也试过,不过,这是一个静态对齐,理想情况下,我希望它是响应性的。要始终在中间对齐,无论大小的问题,寻求代码帮助必须包括最短的代码来复制它本身的问题,最好是在堆栈片段。虽然您提供了一个链接,但如果该链接无效,您的问题对其他将来遇到相同问题的用户将毫无价值。看见