我想知道为什么我的容器 div 向右对齐

发布于 2025-01-10 01:48:44 字数 1026 浏览 3 评论 0原文

[code][1]

看起来有一个边距将容器推向右侧,但是显然,是有的。我很困惑。请帮助

我的代码附在下面

.stat {
  background-color: white;
  border-radius: 12px;
  margin: 3rem;
}

.container {
  margin-top: 8rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.statistic {
  background-color: #F2F2F2;
  margin: 1rem;
  padding: 1rem 8rem;
  border-radius: 12px;
  font-size: small;
  justify-self: center;
}
<div class="stat">
  <div class="container">
    <div class="stat1 statistic">
      <span>86K</span> Students
    </div>
    <div class="stat2 statistic">
      <span>142</span> Tutors
    </div>
    <div class="stat3 statistic">
      <span>900</span> Courses
    </div>
  </div>
</div>

[code][1]

It looks like there is a margin pushing the container to the right but clearly, there is. I'm confused. Please help

My code is attached below

.stat {
  background-color: white;
  border-radius: 12px;
  margin: 3rem;
}

.container {
  margin-top: 8rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.statistic {
  background-color: #F2F2F2;
  margin: 1rem;
  padding: 1rem 8rem;
  border-radius: 12px;
  font-size: small;
  justify-self: center;
}
<div class="stat">
  <div class="container">
    <div class="stat1 statistic">
      <span>86K</span> Students
    </div>
    <div class="stat2 statistic">
      <span>142</span> Tutors
    </div>
    <div class="stat3 statistic">
      <span>900</span> Courses
    </div>
  </div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福%小乖 2025-01-17 01:48:44
.stat{
display : flex;
justify-content : center;
align-items : center;
}

用它来居中你的 div

.stat{
display : flex;
justify-content : center;
align-items : center;
}

Use this to center your div

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文